Browse Source

add includes polifill

Robin Herbots 5 years ago
parent
commit
70af8a3037

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.6-beta.11",
+  "version": "5.0.6-beta.12",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "5.0.6-beta.11",
+  "version": "5.0.6-beta.12",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

File diff suppressed because it is too large
+ 41 - 27
dist/inputmask.js


File diff suppressed because it is too large
+ 2 - 2
dist/inputmask.min.js


File diff suppressed because it is too large
+ 43 - 29
dist/jquery.inputmask.js


File diff suppressed because it is too large
+ 2 - 2
dist/jquery.inputmask.min.js


+ 3 - 1
lib/inputmask.js

@@ -4,7 +4,9 @@
  * Copyright (c) Robin Herbots
  * Licensed under the MIT license
  */
-import "./getPrototypeOf";
+import "./polyfills/Object.getPrototypeOf";
+import "./polyfills/Array.includes";
+
 import {mask} from "./mask";
 import $ from "./dependencyLibs/inputmask.dependencyLib";
 import window from "./global/window";

+ 0 - 1
lib/mask.js

@@ -1,4 +1,3 @@
-import "./getPrototypeOf";
 import keyCode from "./keycode.json";
 import {caret, getBuffer, getBufferTemplate, getLastValidPosition, resetMaskSet, seekNext} from "./positioning";
 import {applyInputValue, clearOptionalTail, writeBuffer} from "./inputHandling";

+ 48 - 0
lib/polyfills/Array.includes.js

@@ -0,0 +1,48 @@
+// https://tc39.github.io/ecma262/#sec-array.prototype.includes
+if (!Array.prototype.includes) {
+	Object.defineProperty(Array.prototype, "includes", {
+		value: function(searchElement, fromIndex) {
+
+			// 1. Let O be ? ToObject(this value).
+			if (this == null) {
+				throw new TypeError("\"this\" is null or not defined");
+			}
+
+			var o = Object(this);
+
+			// 2. Let len be ? ToLength(? Get(O, "length")).
+			var len = o.length >>> 0;
+
+			// 3. If len is 0, return false.
+			if (len === 0) {
+				return false;
+			}
+
+			// 4. Let n be ? ToInteger(fromIndex).
+			//    (If fromIndex is undefined, this step produces the value 0.)
+			var n = fromIndex | 0;
+
+			// 5. If n ≥ 0, then
+			//  a. Let k be n.
+			// 6. Else n < 0,
+			//  a. Let k be len + n.
+			//  b. If k < 0, let k be 0.
+			var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
+
+			// 7. Repeat, while k < len
+			while (k < len) {
+				// a. Let elementK be the result of ? Get(O, ! ToString(k)).
+				// b. If SameValueZero(searchElement, elementK) is true, return true.
+				// c. Increase k by 1.
+				// NOTE: === provides the correct "SameValueZero" comparison needed here.
+				if (o[k] === searchElement) {
+					return true;
+				}
+				k++;
+			}
+
+			// 8. Return false
+			return false;
+		}
+	});
+}

lib/getPrototypeOf.js → lib/polyfills/Object.getPrototypeOf.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.6-beta.11",
+  "version": "5.0.6-beta.12",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "index.js",
   "files": [