-
Notifications
You must be signed in to change notification settings - Fork 77
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
fix(accordion, accordion-item): icon-position
, icon-type
, selection-mode
and scale
can now be set as props or attributes
#7191
Merged
Elijbet
merged 22 commits into
main
from
elijbet/6038-refactor-getElementProp-accordion-item
Jul 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d23b4ee
refactor(accordion, accordion-item): as an outdated pattern
Elijbet e47234f
Merge branch 'master' into elijbet/6038-refactor-getElementProp-accor…
Elijbet 2bb02a3
Merge branch 'master' into elijbet/6038-refactor-getElementProp-accor…
Elijbet f0b2834
refactoring and renaming
Elijbet 5751aec
fix failing tests
Elijbet 9af21d2
for stability, refactor test to check for prop instead of the attribu…
Elijbet 4eea4b5
refactor redundant items prop, owning accordion sets itself as parent…
Elijbet bb4f0e0
Merge branch 'master' into elijbet/6038-refactor-getElementProp-accor…
Elijbet 516057a
Merge branch 'master' into elijbet/6038-refactor-getElementProp-accor…
Elijbet cd18c9b
cleanup
Elijbet cad8ffa
Merge branch 'master' into elijbet/6038-refactor-getElementProp-accor…
Elijbet 4644b25
expand mutationObserver function to retrieve accordion item being add…
Elijbet b90f041
Merge branch 'master' into elijbet/6038-refactor-getElementProp-accor…
Elijbet 5548bff
accordion properties can be set as an attribute as well as a prop tes…
Elijbet 03ff0bc
simplify by updating accordion items by their order in the DOM, remov…
Elijbet bd1f09d
clean up logic that relates to tracking addedItem as no longer necessary
Elijbet 52c5b1b
Merge branch 'main' into elijbet/6038-refactor-getElementProp-accordi…
Elijbet e041429
refactors and cleanup
Elijbet 3390921
simplify updateAccordionItems to remove the use of the private accord…
Elijbet 827c6dd
Merge branch 'main' into elijbet/6038-refactor-getElementProp-accordi…
Elijbet 025912e
test for prop reflects
Elijbet 27638db
Merge branch 'main' into elijbet/6038-refactor-getElementProp-accordi…
Elijbet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm idk how I feel about this. Removing this part will have a performance impact because now the DOM is being queried on every mutation, whereas before it was only being queried when nodes were added.
querySelectorAll
is a pretty intensive task, especially for something like accordion which can have a yuuge amount of child nodes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to query the DOM at all? We should be able to get the added/removed/target nodes from the mutation observer right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateAccordionItems() runs also on watcher for a number of props that are set by parents on children. We need to keep track of items for updateAccordionItems to map set props/prop changes onto them. Looks like at this point that's all updateAccordionItems is doing, as we no longer keep track of position, or items being added because of the query.
Mutation observer track additions, removals, and attribute changes, right? If that's the case why do we even need a watcher? We could just run the update function to sync props on component load in addition to the observer, but we'd need to query still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah now that the constraint of only querying when the mutation included addedNodes is removed, I'm pretty sure the watchers are redundant.
However I'm still concerned about using querySelectorAll on every mutation. There has to be a better way to do this that doesn't have the potential to explode someone's computer. Found this explaination after some googling: https://stackoverflow.com/a/39332340
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, it looks like the MutationObserver isn't set up to observe attributes so I think we would still need to watchers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it's not watching the whole subtree so the performance hit won't be too bad, I guess. Does the current logic cover nested accordions or accordion items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benelan I think this should be fine in terms of perf. The
MutationObserver
is configured to only run on direct child changes (see MutationObserver/observe#childList).