Browse Source

Improve init performance #1489

Robin Herbots 9 years ago
parent
commit
0d9d795351

+ 3 - 0
CHANGELOG.md

@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
 ## [UNRELEASED]
 ### Added
 ### Updates
+- performance updates
+	- initialization
+
 ### Fixed
 - hasOwnProperty check missing in reverseTokens (numericInput) #1486
 - Per-element radixPoint overwrites defaults #1454

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.5-17",
+  "version": "3.3.5-19",
   "main": [
 	  "./dist/inputmask/inputmask.dependencyLib",
 	  "./dist/inputmask/inputmask",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "jquery_inputmask",
 	"repository": "robinherbots/jquery.inputmask",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
-	"version": "3.3.5-17",
+	"version": "3.3.5-19",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.5-17",
+  "version": "3.3.5-19",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask.dependencyLib", [ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 31 - 32
dist/inputmask/inputmask.js

@@ -3,21 +3,19 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask", [ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib")) : factory(window.dependencyLib || jQuery);
 }(function($) {
-    function Inputmask(alias, options) {
-        return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {}, 
-        options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options), 
-        this.maskset = void 0, this.noMasksCache = options && void 0 !== options.definitions, 
-        this.userOptions = options || {}, this.events = {}, this.dataAttribute = "data-inputmask", 
-        this.isRTL = this.opts.numericInput, this.refreshValue = !1, resolveAlias(this.opts.alias, options, this.opts), 
-        void 0) : new Inputmask(alias, options);
+    function Inputmask(alias, options, internal) {
+        return this instanceof Inputmask ? (this.el = void 0, this.events = {}, this.maskset = void 0, 
+        this.refreshValue = !1, void (internal !== !0 && ($.isPlainObject(alias) ? options = alias : (options = options || {}, 
+        options.alias = alias), this.opts = $.extend(!0, {}, this.defaults, options), this.noMasksCache = options && void 0 !== options.definitions, 
+        this.userOptions = options || {}, this.isRTL = this.opts.numericInput, resolveAlias(this.opts.alias, options, this.opts)))) : new Inputmask(alias, options, internal);
     }
     function resolveAlias(aliasStr, options, opts) {
-        var aliasDefinition = opts.aliases[aliasStr];
+        var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
         return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts), 
         $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr), 
         !1);
@@ -1182,6 +1180,7 @@
     }
     var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile, android = /android/i.test(ua) && !iemobile;
     return Inputmask.prototype = {
+        dataAttribute: "data-inputmask",
         defaults: {
             placeholder: "_",
             optionalmarker: {
@@ -1209,7 +1208,6 @@
             clearMaskOnLostFocus: !0,
             insertMode: !0,
             clearIncomplete: !1,
-            aliases: {},
             alias: null,
             onKeyDown: $.noop,
             onBeforeMask: null,
@@ -1232,22 +1230,6 @@
             positionCaretOnTab: !0,
             tabThrough: !1,
             supportsInputType: [ "text", "tel", "password" ],
-            definitions: {
-                "9": {
-                    validator: "[0-9]",
-                    cardinality: 1,
-                    definitionSymbol: "*"
-                },
-                a: {
-                    validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
-                    cardinality: 1,
-                    definitionSymbol: "*"
-                },
-                "*": {
-                    validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
-                    cardinality: 1
-                }
-            },
             ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 ],
             isComplete: null,
             canClearPosition: $.noop,
@@ -1263,6 +1245,23 @@
             colorMask: !1,
             androidHack: !1
         },
+        definitions: {
+            "9": {
+                validator: "[0-9]",
+                cardinality: 1,
+                definitionSymbol: "*"
+            },
+            a: {
+                validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
+                cardinality: 1,
+                definitionSymbol: "*"
+            },
+            "*": {
+                validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
+                cardinality: 1
+            }
+        },
+        aliases: {},
         masksCache: {},
         mask: function(elems) {
             function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
@@ -1299,10 +1298,10 @@
                 var scopedOpts = $.extend(!0, {}, that.opts);
                 importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute);
                 var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
-                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(), 
+                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask((void 0), (void 0), (!0)), 
                 el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), 
-                el.inputmask.el = el, el.inputmask.maskset = maskset, $.data(el, "_inputmask_opts", scopedOpts), 
-                maskScope.call(el.inputmask, {
+                el.inputmask.isRTL = that.isRTL, el.inputmask.el = el, el.inputmask.maskset = maskset, 
+                $.data(el, "_inputmask_opts", scopedOpts), maskScope.call(el.inputmask, {
                     action: "mask"
                 }));
             }), elems && elems[0] ? elems[0].inputmask || this : this;
@@ -1369,7 +1368,7 @@
                 };
             }
             function insertTestDefinition(mtoken, element, position) {
-                var maskdef = opts.definitions[element];
+                var maskdef = (opts.definitions ? opts.definitions[element] : void 0) || Inputmask.prototype.definitions[element];
                 position = void 0 !== position ? position : mtoken.matches.length;
                 var prevMatch = mtoken.matches[position - 1];
                 if (maskdef && !escaped) {
@@ -1506,9 +1505,9 @@
     }, Inputmask.extendDefaults = function(options) {
         $.extend(!0, Inputmask.prototype.defaults, options);
     }, Inputmask.extendDefinitions = function(definition) {
-        $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
+        $.extend(!0, Inputmask.prototype.definitions, definition);
     }, Inputmask.extendAliases = function(alias) {
-        $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
+        $.extend(!0, Inputmask.prototype.aliases, alias);
     }, Inputmask.format = function(value, options, metadata) {
         return Inputmask(options).format(value, metadata);
     }, Inputmask.unmask = function(value, options) {

+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 2 - 2
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
@@ -43,7 +43,7 @@
             phoneCodes: [],
             mask: function(opts) {
                 return opts.definitions = {
-                    "#": opts.definitions[9]
+                    "#": Inputmask.prototype.definitions[9]
                 }, opts.phoneCodes.sort(maskSort);
             },
             keepStatic: !0,

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 32 - 33
dist/jquery.inputmask.bundle.js

@@ -3,19 +3,17 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function($) {
-    function Inputmask(alias, options) {
-        return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {}, 
-        options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options), 
-        this.maskset = void 0, this.noMasksCache = options && void 0 !== options.definitions, 
-        this.userOptions = options || {}, this.events = {}, this.dataAttribute = "data-inputmask", 
-        this.isRTL = this.opts.numericInput, this.refreshValue = !1, resolveAlias(this.opts.alias, options, this.opts), 
-        void 0) : new Inputmask(alias, options);
+    function Inputmask(alias, options, internal) {
+        return this instanceof Inputmask ? (this.el = void 0, this.events = {}, this.maskset = void 0, 
+        this.refreshValue = !1, void (internal !== !0 && ($.isPlainObject(alias) ? options = alias : (options = options || {}, 
+        options.alias = alias), this.opts = $.extend(!0, {}, this.defaults, options), this.noMasksCache = options && void 0 !== options.definitions, 
+        this.userOptions = options || {}, this.isRTL = this.opts.numericInput, resolveAlias(this.opts.alias, options, this.opts)))) : new Inputmask(alias, options, internal);
     }
     function resolveAlias(aliasStr, options, opts) {
-        var aliasDefinition = opts.aliases[aliasStr];
+        var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
         return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts), 
         $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr), 
         !1);
@@ -1180,6 +1178,7 @@
     }
     var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile, android = /android/i.test(ua) && !iemobile;
     return Inputmask.prototype = {
+        dataAttribute: "data-inputmask",
         defaults: {
             placeholder: "_",
             optionalmarker: {
@@ -1207,7 +1206,6 @@
             clearMaskOnLostFocus: !0,
             insertMode: !0,
             clearIncomplete: !1,
-            aliases: {},
             alias: null,
             onKeyDown: $.noop,
             onBeforeMask: null,
@@ -1230,22 +1228,6 @@
             positionCaretOnTab: !0,
             tabThrough: !1,
             supportsInputType: [ "text", "tel", "password" ],
-            definitions: {
-                "9": {
-                    validator: "[0-9]",
-                    cardinality: 1,
-                    definitionSymbol: "*"
-                },
-                a: {
-                    validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
-                    cardinality: 1,
-                    definitionSymbol: "*"
-                },
-                "*": {
-                    validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
-                    cardinality: 1
-                }
-            },
             ignorables: [ 8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 ],
             isComplete: null,
             canClearPosition: $.noop,
@@ -1261,6 +1243,23 @@
             colorMask: !1,
             androidHack: !1
         },
+        definitions: {
+            "9": {
+                validator: "[0-9]",
+                cardinality: 1,
+                definitionSymbol: "*"
+            },
+            a: {
+                validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
+                cardinality: 1,
+                definitionSymbol: "*"
+            },
+            "*": {
+                validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
+                cardinality: 1
+            }
+        },
+        aliases: {},
         masksCache: {},
         mask: function(elems) {
             function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
@@ -1297,10 +1296,10 @@
                 var scopedOpts = $.extend(!0, {}, that.opts);
                 importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute);
                 var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
-                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(), 
+                void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask((void 0), (void 0), (!0)), 
                 el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions), 
-                el.inputmask.el = el, el.inputmask.maskset = maskset, $.data(el, "_inputmask_opts", scopedOpts), 
-                maskScope.call(el.inputmask, {
+                el.inputmask.isRTL = that.isRTL, el.inputmask.el = el, el.inputmask.maskset = maskset, 
+                $.data(el, "_inputmask_opts", scopedOpts), maskScope.call(el.inputmask, {
                     action: "mask"
                 }));
             }), elems && elems[0] ? elems[0].inputmask || this : this;
@@ -1367,7 +1366,7 @@
                 };
             }
             function insertTestDefinition(mtoken, element, position) {
-                var maskdef = opts.definitions[element];
+                var maskdef = (opts.definitions ? opts.definitions[element] : void 0) || Inputmask.prototype.definitions[element];
                 position = void 0 !== position ? position : mtoken.matches.length;
                 var prevMatch = mtoken.matches[position - 1];
                 if (maskdef && !escaped) {
@@ -1504,9 +1503,9 @@
     }, Inputmask.extendDefaults = function(options) {
         $.extend(!0, Inputmask.prototype.defaults, options);
     }, Inputmask.extendDefinitions = function(definition) {
-        $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
+        $.extend(!0, Inputmask.prototype.definitions, definition);
     }, Inputmask.extendAliases = function(alias) {
-        $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
+        $.extend(!0, Inputmask.prototype.aliases, alias);
     }, Inputmask.format = function(value, options, metadata) {
         return Inputmask(options).format(value, metadata);
     }, Inputmask.unmask = function(value, options) {
@@ -2585,7 +2584,7 @@
             phoneCodes: [],
             mask: function(opts) {
                 return opts.definitions = {
-                    "#": opts.definitions[9]
+                    "#": Inputmask.prototype.definitions[9]
                 }, opts.phoneCodes.sort(maskSort);
             },
             keepStatic: !0,

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


+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.min.js

@@ -3,6 +3,6 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-17
+* Version: 3.3.5-19
 */
 !function(a){"function"==typeof define&&define.amd?define("inputmask.dependencyLib",["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

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


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


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


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


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


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


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


+ 42 - 39
js/inputmask.js

@@ -21,33 +21,35 @@
 		iphone = /iphone/i.test(ua) && !iemobile,
 		android = /android/i.test(ua) && !iemobile;
 
-	function Inputmask(alias, options) {
+	function Inputmask(alias, options, internal) {
 		//allow instanciating without new
 		if (!(this instanceof Inputmask)) {
-			return new Inputmask(alias, options);
-		}
-
-		if ($.isPlainObject(alias)) {
-			options = alias;
-		} else {
-			options = options || {};
-			options.alias = alias;
+			return new Inputmask(alias, options, internal);
 		}
 
 		this.el = undefined;
-		//init options
-		this.opts = $.extend(true, {}, this.defaults, options);
-		this.maskset = undefined;
-		this.noMasksCache = options && options.definitions !== undefined;
-		this.userOptions = options || {}; //user passed options
 		this.events = {};
-		this.dataAttribute = "data-inputmask"; //data attribute prefix used for attribute binding
-		this.isRTL = this.opts.numericInput;
-		this.refreshValue = false, //indicate a refresh from the inputvalue is needed (form.reset)
+		this.maskset = undefined;
+		this.refreshValue = false; //indicate a refresh from the inputvalue is needed (form.reset)
+
+		if (internal !== true) {
+			//init options
+			if ($.isPlainObject(alias)) {
+				options = alias;
+			} else {
+				options = options || {};
+				options.alias = alias;
+			}
+			this.opts = $.extend(true, {}, this.defaults, options);
+			this.noMasksCache = options && options.definitions !== undefined;
+			this.userOptions = options || {}; //user passed options
+			this.isRTL = this.opts.numericInput;
 			resolveAlias(this.opts.alias, options, this.opts);
+		}
 	}
 
 	Inputmask.prototype = {
+		dataAttribute: "data-inputmask", //data attribute prefix used for attribute binding
 		//options default
 		defaults: {
 			placeholder: "_",
@@ -76,7 +78,6 @@
 			clearMaskOnLostFocus: true,
 			insertMode: true, //insert the input or overwrite the input
 			clearIncomplete: false, //clear the incomplete input on blur
-			aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
 			alias: null,
 			onKeyDown: $.noop, //callback to implement autocomplete on certain keys for example. args => event, buffer, caretPos, opts
 			onBeforeMask: null, //executes before masking the initial value to allow preprocessing of the initial value.	args => initialValue, opts => return processedValue
@@ -101,22 +102,6 @@
 			positionCaretOnTab: true, //when enabled the caret position is set after the latest valid position on TAB
 			tabThrough: false, //allows for tabbing through the different parts of the masked field
 			supportsInputType: ["text", "tel", "password"], //list with the supported input types
-			definitions: {
-				"9": {
-					validator: "[0-9]",
-					cardinality: 1,
-					definitionSymbol: "*"
-				},
-				"a": {
-					validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-					cardinality: 1,
-					definitionSymbol: "*"
-				},
-				"*": {
-					validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-					cardinality: 1
-				}
-			},
 			//specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
 			ignorables: [8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
 			isComplete: null, //override for isComplete - args => buffer, opts - return true || false
@@ -133,6 +118,23 @@
 			colorMask: false, //enable css styleable mask
 			androidHack: false //see README_android.md
 		},
+		definitions: {
+			"9": {
+				validator: "[0-9]",
+				cardinality: 1,
+				definitionSymbol: "*"
+			},
+			"a": {
+				validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
+				cardinality: 1,
+				definitionSymbol: "*"
+			},
+			"*": {
+				validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
+				cardinality: 1
+			}
+		},
+		aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
 		masksCache: {},
 		mask: function (elems) {
 			var that = this;
@@ -203,10 +205,11 @@
 						el.inputmask.remove();
 					}
 					//store inputmask instance on the input with element reference
-					el.inputmask = new Inputmask();
+					el.inputmask = new Inputmask(undefined, undefined, true);
 					el.inputmask.opts = scopedOpts;
 					el.inputmask.noMasksCache = that.noMasksCache;
 					el.inputmask.userOptions = $.extend(true, {}, that.userOptions);
+					el.inputmask.isRTL = that.isRTL;
 					el.inputmask.el = el;
 					el.inputmask.maskset = maskset;
 
@@ -308,7 +311,7 @@
 
 			//test definition => {fn: RegExp/function, cardinality: int, optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
 			function insertTestDefinition(mtoken, element, position) {
-				var maskdef = opts.definitions[element];
+				var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element];
 				position = position !== undefined ? position : mtoken.matches.length;
 				var prevMatch = mtoken.matches[position - 1];
 				if (maskdef && !escaped) {
@@ -553,10 +556,10 @@
 		$.extend(true, Inputmask.prototype.defaults, options);
 	};
 	Inputmask.extendDefinitions = function (definition) {
-		$.extend(true, Inputmask.prototype.defaults.definitions, definition);
+		$.extend(true, Inputmask.prototype.definitions, definition);
 	};
 	Inputmask.extendAliases = function (alias) {
-		$.extend(true, Inputmask.prototype.defaults.aliases, alias);
+		$.extend(true, Inputmask.prototype.aliases, alias);
 	};
 	//static fn on inputmask
 	Inputmask.format = function (value, options, metadata) {
@@ -615,7 +618,7 @@
 	};
 
 	function resolveAlias(aliasStr, options, opts) {
-		var aliasDefinition = opts.aliases[aliasStr];
+		var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
 		if (aliasDefinition) {
 			if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
 			$.extend(true, opts, aliasDefinition); //merge alias definition in the options

+ 1 - 1
js/inputmask.phone.extensions.js

@@ -92,7 +92,7 @@
 			countrycode: "",
 			phoneCodes: [],
 			mask: function (opts) {
-				opts.definitions = {"#": opts.definitions["9"]};
+				opts.definitions = {"#": Inputmask.prototype.definitions["9"]};
 				return opts.phoneCodes.sort(maskSort);
 			},
 			keepStatic: true,

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 	"name": "jquery.inputmask",
-	"version": "3.3.5-17",
+	"version": "3.3.5-19",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
 	"main": "index.js",
 	"files": [

+ 1 - 1
qunit/tests_phone_world.js

@@ -26,7 +26,7 @@ define([
 
 		testmask.focus();
 
-		$.each(Inputmask.prototype.defaults.aliases.phone.phoneCodes, function (ndx, lmnt) {
+		$.each(Inputmask.prototype.aliases.phone.phoneCodes, function (ndx, lmnt) {
 			var ndx = 1, input, expected = lmnt.mask;
 			while (expected.match(/#/)) {
 				expected = expected.replace(/#/, ndx++);

+ 1 - 1
qunit/tests_phonebe.js

@@ -26,7 +26,7 @@ define([
 
 		testmask.focus();
 
-		$.each(Inputmask.prototype.defaults.aliases.phonebe.phoneCodes, function (ndx, lmnt) {
+		$.each(Inputmask.prototype.aliases.phonebe.phoneCodes, function (ndx, lmnt) {
 			var ndx = 1, input, expected = lmnt.mask;
 			while (expected.match(/#/)) {
 				expected = expected.replace(/#/, ndx++);

+ 1 - 1
qunit/tests_phonenl.js

@@ -26,7 +26,7 @@ define([
 
 		testmask.focus();
 
-		$.each(Inputmask.prototype.defaults.aliases.phonenl.phoneCodes, function (ndx, lmnt) {
+		$.each(Inputmask.prototype.aliases.phonenl.phoneCodes, function (ndx, lmnt) {
 			var ndx = 1, input, expected = lmnt.mask;
 			while (expected.match(/#/)) {
 				expected = expected.replace(/#/, ndx++);

+ 2 - 2
qunit/tests_phoneru.js

@@ -19,7 +19,7 @@ define([
 	qunit.module("Phoneru masks");
 
 
-	for (var i = 0; i < Inputmask.prototype.defaults.aliases.phoneru.phoneCodes.length; i += 25) {
+	for (var i = 0; i < Inputmask.prototype.aliases.phoneru.phoneCodes.length; i += 25) {
 		qunit.test("inputmask(\"phoneru\") - " + i + "-" + (i + 25), function (assert) {
 				var i = assert.test.testName.match(/\d+$/);
 				i = i - 25;
@@ -30,7 +30,7 @@ define([
 
 				testmask.focus();
 
-				$.each(Inputmask.prototype.defaults.aliases.phoneru.phoneCodes.slice(i, i + 25), function (ndx, lmnt) {
+				$.each(Inputmask.prototype.aliases.phoneru.phoneCodes.slice(i, i + 25), function (ndx, lmnt) {
 					var ndx = 1, input, expected = lmnt.mask;
 					while (expected.match(/#/)) {
 						expected = expected.replace(/#/, ndx++);