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

speed up getAdjacentEl #726

Merged
merged 2 commits into from Oct 31, 2019
Merged

speed up getAdjacentEl #726

merged 2 commits into from Oct 31, 2019

Conversation

tinovyatkin
Copy link
Contributor

@tinovyatkin tinovyatkin commented Oct 30, 2019

Current implementation uses Array.from(parentElement.querySelectorAll()).indexOf etc. While in major amount of use cases the element we are looking for is immediately accessible by nextElementSiblings or previousElementSiblings.

Also changing parameter from a number to string for easier to understand and more error-proof code.

@tinovyatkin tinovyatkin changed the title use element accessors speed up getAdjacentEl Oct 30, 2019
@jshjohnson jshjohnson added the refactor Pull request that refactors existing functionality label Oct 31, 2019
Copy link
Collaborator

@jshjohnson jshjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@jshjohnson jshjohnson merged commit 5afe8b5 into Choices-js:master Oct 31, 2019
@tinovyatkin tinovyatkin deleted the get-adjacent-el branch October 31, 2019 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull request that refactors existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants