You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just reviewed a piece of code with DOM queries in computed prop. This is subtly wrong, because the computed is not recomputed when DOM changes. The right way to do this is to either use ref binding in template or query the DOM in event handlers where the element is needed.
What category should the rule belong to?
[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
constcurrent=ref(0)// following computed is only updated when `current` changes, but not when DOM changesconstcurrentPostElement=computed(()=>document.querySelectorAll('post')[current.value])
The text was updated successfully, but these errors were encountered:
panstromek
changed the title
Add rule to warn agains DOM queries in computed
Add rule to warn against DOM queries in computed
Aug 17, 2024
Please describe what the rule should do:
I've just reviewed a piece of code with DOM queries in computed prop. This is subtly wrong, because the computed is not recomputed when DOM changes. The right way to do this is to either use ref binding in template or query the DOM in event handlers where the element is needed.
What category should the rule belong to?
[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
The text was updated successfully, but these errors were encountered: