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

fix: guard usage of Array methods on nodelist and htmlcollection #1546

Closed

Conversation

ravijayaramappa
Copy link
Contributor

Details

Legacy third party libraries that patch prototype of Array intrinsic are incapable of handling NodeList and HTMLCollection instances. For example, one such library is older version(1.7) of prototype.js
So this PR is to guard lwc engine against such legacy libraries by writing its own custom utils.

Fixes #1545

Does this PR introduce breaking changes?

  • No, it does not introduce breaking changes.

If yes, please describe the impact and migration path for existing applications.

The PR fulfills these requirements:

  • Have tests for the proposed changes been added? ✅
  • Have you followed these instructions to clearly describe the issue being fixed or feature enhanced? ✅

@ravijayaramappa ravijayaramappa added this to the 224 milestone Sep 30, 2019
Copy link
Member

@ekashida ekashida left a comment

Choose a reason for hiding this comment

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

Thinking about this more, I think I would prefer an approach where we use Array.from or implement something similar to convert all of these collections into arrays before operating on them with array methods. We could then enforce this by adding assertions for all array methods so that they only operate on array instances. Thoughts?

@ravijayaramappa
Copy link
Contributor Author

Closing in favor of #1548

@ravijayaramappa ravijayaramappa deleted the ravi/master/custom-collection-util/W-6684382 branch October 22, 2019 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invoking Array.prototype methods on nodelist/htmlcollection fails because of third party libraries
2 participants