MCPcopy
hub / github.com/ampproject/amphtml / patchValhook

Function patchValhook

third_party/inputmask/inputmask.js:2484–2515  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

2482 var valueGet;
2483 var valueSet;
2484 function patchValhook(type) {
2485 if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== true)) {
2486 var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
2487 return elem.value;
2488 };
2489 var valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
2490 elem.value = value;
2491 return elem;
2492 };
2493 $.valHooks[type] = {
2494 get: function(elem) {
2495 if (elem.inputmask) {
2496 if (elem.inputmask.opts.autoUnmask) {
2497 return elem.inputmask.unmaskedvalue();
2498 } else {
2499 var result = valhookGet(elem);
2500 return getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== true ? result : "";
2501 }
2502 } else return valhookGet(elem);
2503 },
2504 set: function(elem, value) {
2505 var $elem = $(elem), result;
2506 result = valhookSet(elem, value);
2507 if (elem.inputmask) {
2508 $elem.trigger("setvalue", [ value ]);
2509 }
2510 return result;
2511 },
2512 inputmaskpatch: true
2513 };
2514 }
2515 }
2516 function getter() {
2517 if (this.inputmask) {
2518 return this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : getLastValidPosition() !== -1 || opts.nullable !== true ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "";

Callers 1

patchValuePropertyFunction · 0.85

Calls 3

getLastValidPositionFunction · 0.85
$Function · 0.70
triggerMethod · 0.45

Tested by

no test coverage detected