mirror of https://github.com/layui/layui
优化 lay 构造器,以适配选择器为自身对象的情况
parent
8de9a9c043
commit
365b159a18
|
@ -12,12 +12,15 @@
|
||||||
return new LAY(selector);
|
return new LAY(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
//DOM构造器
|
// DOM 构造器
|
||||||
,LAY = function(selector){
|
,LAY = function(selector){
|
||||||
var index = 0
|
var index = 0;
|
||||||
,nativeDOM = typeof selector === 'object' ? [selector] : (
|
var nativeDOM = typeof selector === 'object' ? function(){
|
||||||
this.selector = selector
|
// 仅适配简单元素对象
|
||||||
,document.querySelectorAll(selector || null)
|
return layui.isArray(selector) ? selector : [selector];
|
||||||
|
}() : (
|
||||||
|
this.selector = selector,
|
||||||
|
document.querySelectorAll(selector || null)
|
||||||
);
|
);
|
||||||
for(; index < nativeDOM.length; index++){
|
for(; index < nativeDOM.length; index++){
|
||||||
this.push(nativeDOM[index]);
|
this.push(nativeDOM[index]);
|
||||||
|
|
Loading…
Reference in New Issue