fix: prevent duplicative array observation patch #5654
Merged
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.
Pull Request
📖 Description
In the event that two copies of
fast-element
are loaded into the same browser context, this PR prevents doubly patching of Array methods🎫 Issues
👩💻 Reviewer Notes
It's important to note that we still need to configure the array observer factory per library instance but we don't want to patch Array more than once, since that's global.
Please also review #5656
📑 Test Plan
Nearly impossible to test this. All current tests still pass.
✅ Checklist
General
$ yarn change
⏭ Next Steps
There are likely other problems with having two instances of
fast-element
on the same page, particularly around looking up element definitions, observing objects built on different versions of the library, etc. We should look into whether there are ways to address these other issues as part of FASTElement 2.0. Standard decorator metadata will help with some of this eventually, but that won't land in time for FE2.0, so we can try to adopt a temporary solution with the same behavior.