New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description of prefer-query-selector
is misleading WRT “consistency”
#342
Comments
"Consistency" as in always using the same method that behaves the same.
I'm well aware of how they work. But sure, we can make the difference clearer. |
@sindresorhus I can do it. |
Removed the word consistent, which seemed to cause confusion
) * Fix for issue #342 Removed the word consistent, which seemed to cause confusion * Update prefer-query-selector.md * Update docs/rules/prefer-query-selector.md Co-Authored-By: fisker Cheung <lionkay@gmail.com>
This rule basically breaks code that relies on a "live" HTMLCollection returned by .getElementsByTagName() and .getElementsByClassName(). I was under impression that linters are NOT supposed to change code functionality, and |
The description of the
prefer-query-selector
rule states:"Consistency" has nothing to do here. These methods aren't synonymous with each other:
.getElementsByTagName()
and.getElementsByClassName()
return anHTMLCollection
object, which updates dynamically as elements are added or removed from the DOM:Conversely,
.querySelectorAll()
returns a staticNodeList
which does not reflect changes to the DOM:The rule — or at least its description — should be amended to acknowledge this.
The text was updated successfully, but these errors were encountered: