arale-autocomplete
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -60,3 +60,3 @@ # 数据源 | ||
trigger: '#acTrigger3', | ||
dataSource: function(value) { | ||
dataSource: function(value, done) { | ||
var that = this; | ||
@@ -67,7 +67,5 @@ $.ajax('./data.json', { | ||
.success(function(data) { | ||
that.trigger('data', data.concat(local)); | ||
done(data.concat(local)); | ||
}) | ||
.error(function(data) { | ||
that.trigger('data', {}); | ||
}); | ||
.error(done); | ||
}, | ||
@@ -74,0 +72,0 @@ width: 150 |
@@ -45,3 +45,3 @@ # 其他示例 | ||
````javascript | ||
seajs.use('../src/autocomplete.css'); | ||
seajs.use('select.css'); | ||
seajs.use(['autocomplete', './other.handlebars'], function(AutoComplete, template) { | ||
@@ -51,3 +51,3 @@ ac = new AutoComplete({ | ||
template: template, | ||
selectItem: false, | ||
width: '200' | ||
dataSource: [ | ||
@@ -54,0 +54,0 @@ '信用卡', |
@@ -5,2 +5,10 @@ # History | ||
## 1.4.1 | ||
`tag:fixed` 修复 for/in 数组的 bug | ||
`tag:fixed` #98 模板中不应该使用 javascript:\'\' | ||
`tag:fixed` _handleSelection 中 data 为空的情况 | ||
## 1.4.0 | ||
@@ -7,0 +15,0 @@ |
{ | ||
"name": "arale-autocomplete", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "自动补全组件", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -30,3 +30,3 @@ var $ = require('spm-jquery'); | ||
return function () { | ||
val.apply(that, arguments); | ||
return val.apply(that, arguments); | ||
}; | ||
@@ -243,2 +243,3 @@ } | ||
_handleSelection: function (e) { | ||
if (!this.items) return; | ||
var isMouse = e ? e.type === 'click' : false; | ||
@@ -249,3 +250,3 @@ var index = isMouse ? this.items.index(e.currentTarget) : this.get('selectedIndex'); | ||
if (index >= 0 && item) { | ||
if (index >= 0 && item && data) { | ||
this.input.setValue(data.label); | ||
@@ -490,2 +491,2 @@ this.set('selectedIndex', index, { | ||
return v; | ||
} | ||
} |
@@ -97,3 +97,8 @@ var Base = require('arale-base'); | ||
func = this.get('source'); | ||
// 如果返回 false 可阻止执行 | ||
var data = func.call(this, query, done); | ||
if (data) { | ||
this._done(data); | ||
} | ||
@@ -103,6 +108,2 @@ function done(data) { | ||
} | ||
var data = func.call(this, query, done); | ||
if (data) { | ||
this._done(data); | ||
} | ||
} | ||
@@ -121,2 +122,2 @@ }); | ||
}); | ||
} | ||
} |
@@ -30,3 +30,5 @@ var sinon = require('spm-sinon'); | ||
trigger: '#test', | ||
dataSource: ['abc', 'abd', 'cbd'] | ||
dataSource: function() { | ||
return ['abc', 'abd', 'cbd']; | ||
} | ||
}).render(); | ||
@@ -592,2 +594,11 @@ | ||
}); | ||
it('should not contain a #98', function() { | ||
ac = new AutoComplete({ | ||
trigger: '#test', | ||
dataSource: ['abc', 'abd', 'abe'] | ||
}).render(); | ||
ac.setInputValue('a'); | ||
expect(ac.items.eq(0).find('a')[0]).to.be(undefined); | ||
}); | ||
}); | ||
@@ -594,0 +605,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
0
1
74774
25
1668