Skip to content
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

DOM traversing rules suggestions #345

Open
fregante opened this issue Aug 19, 2019 · 4 comments
Open

DOM traversing rules suggestions #345

fregante opened this issue Aug 19, 2019 · 4 comments

Comments

@fregante
Copy link
Collaborator

More readable

  • .childNodes[0] -> .firstChild
  • .children[0] -> .firstElementChild

More robust

  • .children[1] -> .querySelector('selector')
  • .children[1].children[2] -> .querySelector('selector')
  • .parentElement.parentElement -> .closest('selector')
  • .querySelector('a').querySelector('b') -> .querySelector('a b')
@sindresorhus
Copy link
Owner

Any rule name suggestions?

@Manu1400
Copy link

I have code for :

  • .childNodes[0] -> .firstChild
  • .children[0] -> .firstElementChild
  • .querySelector('a').querySelector('b') -> .querySelector('a b')

But i don't have idea for a rule name.

@fregante
Copy link
Collaborator Author

fregante commented Aug 22, 2019

better-dom-traversing? readable-*? Safer?

@sindresorhus
Copy link
Owner

I like better-dom-traversing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants