summaryrefslogtreecommitdiffstats
path: root/awesomplete.js
diff options
context:
space:
mode:
authorVladislav Zarakovsky <vlad.zar@gmail.com>2016-01-28 17:33:35 +0300
committerVladislav Zarakovsky <vlad.zar@gmail.com>2016-01-28 17:33:35 +0300
commitde410fe612fa1431f3be885835de3ac740ceb42b (patch)
treee56aa0ef9e40af24724b6ace3f7e30b5b7c8cee9 /awesomplete.js
parenta29774b4ba349b90848c9de5acfe3d802e85fc88 (diff)
downloadawesomplete-de410fe612fa1431f3be885835de3ac740ceb42b.zip
awesomplete-de410fe612fa1431f3be885835de3ac740ceb42b.tar.gz
awesomplete-de410fe612fa1431f3be885835de3ac740ceb42b.tar.bz2
Pass instance to configure instead of call(this)
Why use configure.call(this, defaults, o) if we could just do configure(this, defaults, o)? This also reduces minified code size.
Diffstat (limited to 'awesomplete.js')
-rw-r--r--awesomplete.js18
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;
}
}
}