Make sure elements are unqiue after concat

This commit is contained in:
mozbug 2020-03-04 22:40:57 +08:00
parent 08c6d475c6
commit 972f80b88e
2 changed files with 3 additions and 1 deletions

View file

@ -748,7 +748,8 @@ function pushSpace() {
export function hintables(selectors = DOM.HINTTAGS_selectors, withjs = false) {
let elems = DOM.getElemsBySelector(selectors, [])
if (withjs) {
elems = [...elems, ...DOM.hintworthy_js_elems]
const elemSet = new Set([...elems, ...DOM.hintworthy_js_elems])
elems = [...elemSet]
}
return elems.filter(DOM.isVisible)
}

View file

@ -229,6 +229,7 @@ export function isVisible(element: Element) {
}
// remove elements that are barely within the viewport, tiny, or invisible
// Only call getComputedStyle when necessary
const computedStyle = getComputedStyle(element)
switch (true) {
case widthMatters(computedStyle) && clientRect.width < 3: