mirror of
https://gitee.com/layui/layui.git
synced 2025-10-26 18:59:15 +08:00
优化 lay 构造器,以适配选择器为自身对象的情况
This commit is contained in:
@@ -12,12 +12,15 @@
|
||||
return new LAY(selector);
|
||||
}
|
||||
|
||||
//DOM构造器
|
||||
// DOM 构造器
|
||||
,LAY = function(selector){
|
||||
var index = 0
|
||||
,nativeDOM = typeof selector === 'object' ? [selector] : (
|
||||
this.selector = selector
|
||||
,document.querySelectorAll(selector || null)
|
||||
var index = 0;
|
||||
var nativeDOM = typeof selector === 'object' ? function(){
|
||||
// 仅适配简单元素对象
|
||||
return layui.isArray(selector) ? selector : [selector];
|
||||
}() : (
|
||||
this.selector = selector,
|
||||
document.querySelectorAll(selector || null)
|
||||
);
|
||||
for(; index < nativeDOM.length; index++){
|
||||
this.push(nativeDOM[index]);
|
||||
|
||||
Reference in New Issue
Block a user