forked from ampproject/amphtml
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛🏗 Fix mask appearing on hover. Use patch pattern (ampproject#19873)
* Fix mask appearing on hover. Use patch pattern * Add wildcard patch
- Loading branch information
Showing
11 changed files
with
1,235 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
URL: https://github.com/RobinHerbots/Inputmask/tree/4.x | ||
URL: https://github.com/RobinHerbots/Inputmask/tree/3.x | ||
License: MIT | ||
License File: https://github.com/RobinHerbots/Inputmask/blob/4.x/LICENSE.txt | ||
License File: https://github.com/RobinHerbots/Inputmask/blob/3.x/LICENSE.txt | ||
|
||
Description: | ||
Copy of inputmask library and dependency library from release 4.x | ||
https://github.com/vega/vega/tree/4.x | ||
Copy of inputmask library and dependency library from release 3.x | ||
https://github.com/RobinHerbots/Inputmask/tree/3.x | ||
|
||
Local Modifications: | ||
Replace the universal module definition with a factory wrapper. | ||
Changed initial unmask behavior when value patching is disabled. | ||
Altered trigger implementation to not use CustomElement for triggering events | ||
- Patch 0000: Replace the universal module definition with a factory wrapper. | ||
- Patch 0001: Reference Element from the global object dependency-injected into | ||
the factory. This fixes behavior across iframe boundaries, like in tests. | ||
- Patch 0002: Changed initial unmask behavior when value patching is disabled. | ||
- Patch 0003: In `trigger` implementation, only use CustomEvent for custom | ||
events, and use native Events for code-initiated user events like "click". | ||
- Patch 0004: Check for showMaskOnHover in the mouseenter handler. | ||
- Patch 0005: Remove extraneous whitespace. | ||
- Patch 0006: Add support for the "?" mask character as a wildcard character. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
# Run this file with bash to add AMP-specific changes to the | ||
# inputmask library. | ||
|
||
# Apply all the patches in third_party/inputmask/patches/ | ||
for patchfile in patches/*.patch | ||
do | ||
echo "Applying patch $patchfile" | ||
patch < $patchfile | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
third_party/inputmask/patches/0000-remove-umd-wrapper.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
diff --git a/third_party/inputmask/inputmask.dependencyLib.js b/third_party/inputmask/inputmask.dependencyLib.js | ||
index 3916874f1..dabe6c770 100755 | ||
--- a/third_party/inputmask/inputmask.dependencyLib.js | ||
+++ b/third_party/inputmask/inputmask.dependencyLib.js | ||
@@ -6,9 +6,7 @@ | ||
* Version: 3.3.11 | ||
*/ | ||
|
||
-!function(factory) { | ||
- "function" == typeof define && define.amd ? define([ "../global/window", "../global/document" ], factory) : "object" == typeof exports ? module.exports = factory(require("../global/window"), require("../global/document")) : window.dependencyLib = factory(window, document); | ||
-}(function(window, document) { | ||
+export function factory(window, document) { | ||
function indexOf(list, elem) { | ||
for (var i = 0, len = list.length; i < len; i++) if (list[i] === elem) return i; | ||
return -1; | ||
@@ -130,4 +128,4 @@ | ||
return evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail), | ||
evt; | ||
}, DependencyLib.Event.prototype = window.Event.prototype), DependencyLib; | ||
-}); | ||
\ No newline at end of file | ||
+} | ||
diff --git a/third_party/inputmask/inputmask.js b/third_party/inputmask/inputmask.js | ||
index c6836be84..71f7b99b6 100644 | ||
--- a/third_party/inputmask/inputmask.js | ||
+++ b/third_party/inputmask/inputmask.js | ||
@@ -6,9 +6,7 @@ | ||
* Version: 3.3.11 | ||
*/ | ||
|
||
-!function(factory) { | ||
- "function" == typeof define && define.amd ? define([ "./dependencyLibs/inputmask.dependencyLib", "./global/window", "./global/document" ], factory) : "object" == typeof exports ? module.exports = factory(require("./dependencyLibs/inputmask.dependencyLib"), require("./global/window"), require("./global/document")) : window.Inputmask = factory(window.dependencyLib || jQuery, window, document); | ||
-}(function($, window, document, undefined) { | ||
+export function factory($, window, document, undefined) { | ||
function Inputmask(alias, options, internal) { | ||
if (!(this instanceof Inputmask)) return new Inputmask(alias, options, internal); | ||
this.el = undefined, this.events = {}, this.maskset = undefined, this.refreshValue = !1, | ||
@@ -1622,4 +1620,4 @@ | ||
WINDOWS: 91, | ||
X: 88 | ||
}, Inputmask; | ||
-}); | ||
\ No newline at end of file | ||
+} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/third_party/inputmask/inputmask.dependencyLib.js b/third_party/inputmask/inputmask.dependencyLib.js | ||
index dabe6c770..aff110fc5 100755 | ||
--- a/third_party/inputmask/inputmask.dependencyLib.js | ||
+++ b/third_party/inputmask/inputmask.dependencyLib.js | ||
@@ -22,7 +22,7 @@ export function factory(window, document) { | ||
return "function" !== ltype && !isWindow(obj) && (!(1 !== obj.nodeType || !length) || ("array" === ltype || 0 === length || "number" == typeof length && length > 0 && length - 1 in obj)); | ||
} | ||
function isValidElement(elem) { | ||
- return elem instanceof Element; | ||
+ return elem instanceof window.Element; | ||
} | ||
function DependencyLib(elem) { | ||
return elem instanceof DependencyLib ? elem : this instanceof DependencyLib ? void (void 0 !== elem && null !== elem && elem !== window && (this[0] = elem.nodeName ? elem : void 0 !== elem[0] && elem[0].nodeName ? elem[0] : document.querySelector(elem), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/third_party/inputmask/inputmask.dependencyLib.js b/third_party/inputmask/inputmask.dependencyLib.js | ||
index dabe6c770..509e91dd2 100755 | ||
--- a/third_party/inputmask/inputmask.dependencyLib.js | ||
+++ b/third_party/inputmask/inputmask.dependencyLib.js | ||
@@ -80,7 +80,7 @@ export function factory(window, document) { | ||
}; | ||
if (document.createEvent) { | ||
try { | ||
- evnt = new CustomEvent(ev, params); | ||
+ evnt = ["change","input","click"].indexOf(ev) > -1 ? new Event(ev, params) : new CustomEvent(ev, params); | ||
} catch (e) { | ||
(evnt = document.createEvent("CustomEvent")).initCustomEvent(ev, params.bubbles, params.cancelable, params.detail); | ||
} |
13 changes: 13 additions & 0 deletions
13
third_party/inputmask/patches/0003-fix-unpatched-unmask.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/third_party/inputmask/inputmask.js b/third_party/inputmask/inputmask.js | ||
index 71f7b99b6..215e86839 100644 | ||
--- a/third_party/inputmask/inputmask.js | ||
+++ b/third_party/inputmask/inputmask.js | ||
@@ -1324,7 +1324,7 @@ export function factory($, window, document, undefined) { | ||
var scopedOpts = $.extend(!0, {}, that.opts); | ||
importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute); | ||
var maskset = generateMaskSet(scopedOpts, that.noMasksCache); | ||
- maskset !== undefined && (el.inputmask !== undefined && (el.inputmask.opts.autoUnmask = !0, | ||
+ maskset !== undefined && (el.inputmask !== undefined && (el.inputmask.opts.autoUnmask = el.inputmask.opts.autoUnmask, | ||
el.inputmask.remove()), el.inputmask = new Inputmask(undefined, undefined, !0), | ||
el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), | ||
el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput, el.inputmask.el = el, |
13 changes: 13 additions & 0 deletions
13
third_party/inputmask/patches/0004-fix-unpatched-hover.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/third_party/inputmask/inputmask.js b/third_party/inputmask/inputmask.js | ||
index c6836be84..ac471bcf3 100644 | ||
--- a/third_party/inputmask/inputmask.js | ||
+++ b/third_party/inputmask/inputmask.js | ||
@@ -1127,7 +1127,7 @@ | ||
}(npt.type), function(npt) { | ||
EventRuler.on(npt, "mouseenter", function(event) { | ||
var $input = $(this); | ||
- this.inputmask._valueGet() !== getBuffer().join("") && $input.trigger("setvalue"); | ||
+ opts.showMaskOnHover == !0 && this.inputmask._valueGet() !== getBuffer().join("") && $input.trigger("setvalue"); | ||
}); | ||
}(npt)); | ||
} |
Oops, something went wrong.