import _app from './../app.js';
import wx from './wx'
module.exports = class SelectorQuery {
constructor() {
this.val = [];
}
select(selector) {
let element = this.getSelectorFindId(selector);
return element;
}
jumpToElement(element) {
let listdom = weex.requireModule('dom');
listdom.scrollToElement(element, {});
}
getSelectorFindId(id) {
let a = id;
if(a.substr(0,1) == "#"){
a = a.substr(1);
}
let obj = _app.getCurrentInstance();
let children = obj.$refs.system_scroll.children;
// wx.alert(children);
// return;
let result = this.findElement(children,a);
//wx.alert(result);
return result;
}
findElement(children,id){
if (children) {
for (let i = 0; i < children.length; ++i) {
if (children[i].attr.id == id) {
return children[i];
}
let new_children = children[i].children;
if(new_children){
return this.findElement(new_children,id);
}
}
}
return false;
}
}