diff options
author | Lea Verou <lea@verou.me> | 2016-01-28 17:55:22 +0200 |
---|---|---|
committer | Lea Verou <lea@verou.me> | 2016-01-28 17:55:22 +0200 |
commit | beff6382cce9676272ef5418851683b8b07c95d7 (patch) | |
tree | e56aa0ef9e40af24724b6ace3f7e30b5b7c8cee9 | |
parent | a29774b4ba349b90848c9de5acfe3d802e85fc88 (diff) | |
parent | de410fe612fa1431f3be885835de3ac740ceb42b (diff) | |
download | awesomplete-beff6382cce9676272ef5418851683b8b07c95d7.zip awesomplete-beff6382cce9676272ef5418851683b8b07c95d7.tar.gz awesomplete-beff6382cce9676272ef5418851683b8b07c95d7.tar.bz2 |
Merge pull request #16829 from vlazar/feature/simplify-configure
Pass instance to configure instead of call(this)
-rw-r--r-- | awesomplete.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/awesomplete.js b/awesomplete.js index b4bf9af..06391ef 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -18,7 +18,7 @@ var _ = function (input, o) { o = o || {}; - configure.call(this, { + configure(this, { minChars: 2, maxItems: 10, autoFirst: false, @@ -262,26 +262,26 @@ _.SORT_BYLENGTH = function (a, b) { // Private functions -function configure(properties, o) { +function configure(instance, properties, o) { for (var i in properties) { var initial = properties[i], - attrValue = this.input.getAttribute("data-" + i.toLowerCase()); + attrValue = instance.input.getAttribute("data-" + i.toLowerCase()); if (typeof initial === "number") { - this[i] = parseInt(attrValue); + instance[i] = parseInt(attrValue); } else if (initial === false) { // Boolean options must be false by default anyway - this[i] = attrValue !== null; + instance[i] = attrValue !== null; } else if (initial instanceof Function) { - this[i] = null; + instance[i] = null; } else { - this[i] = attrValue; + instance[i] = attrValue; } - if (!this[i] && this[i] !== 0) { - this[i] = (i in o)? o[i] : initial; + if (!instance[i] && instance[i] !== 0) { + instance[i] = (i in o)? o[i] : initial; } } } |