Skip to content

Commit

Permalink
fix(taro-h5/api): selectorQuery api 去掉缓存dom节点的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed May 11, 2018
1 parent 9c97f56 commit 6b618ab
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/taro-h5/src/api/createSelectorQuery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,16 @@
*/
function queryBat (queue, cb) {
const res = []
const cached = {}

queue.forEach(item => {
const { selector, single, fields } = item
let el = null

if (single) {
if (cached[selector] && cached[selector].single) {
el = cached[selector].el
} else {
el = document.querySelector(selector)
cached[selector] = { single, el }
}
el = document.querySelector(selector)
res.push(filter(fields, el, selector))
} else {
if (cached[selector] && !cached[selector].single) {
el = cached[selector].el
} else {
el = Array.from(document.querySelectorAll(selector))
cached[selector] = { single, el }
}
el = Array.from(document.querySelectorAll(selector))
res.push(el.map(dom => filter(fields, dom)))
}
})
Expand Down

0 comments on commit 6b618ab

Please sign in to comment.