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(dom): prevent iteration over deleted items #514

Merged
merged 2 commits into from
Jul 19, 2023
Merged

fix(dom): prevent iteration over deleted items #514

merged 2 commits into from
Jul 19, 2023

Conversation

karfau
Copy link
Member

@karfau karfau commented Jul 16, 2023

  • NodeList.item now checks the length attribute before accessing the item at a provided index and returns null it the index is out of range
  • when updating LiveNodeList (as part of accessing the item method) and the new length is shorter then the current one, any references on indexes following the index starting from length are deleted, and null is returned instead of undefined
  • added some exports to the lib/dom.js module to enable testing

fixes #499

@karfau karfau added this to the 0.9.0 milestone Jul 16, 2023
test/dom/node-list.test.js Fixed Show fixed Hide fixed
@karfau
Copy link
Member Author

karfau commented Jul 16, 2023

@qtow from what I understood in your issue report, this should fix it in all the ways I could think of.

Do you have a way to verify it before landing the PR? Or would you suggest to add any test?
(I just made sure the changed lines are covered by tests.)

If you are not able to, I can land and release it as part of the next pre-release for 0.9.0 and once you verified that, I would provide a backports for the versions 0.8 and 0.7

@karfau karfau merged commit 7cef79e into master Jul 19, 2023
33 checks passed
@karfau karfau deleted the 499 branch July 19, 2023 10:27
karfau added a commit that referenced this pull request Jul 19, 2023
- `NodeList.item` now checks the `length` attribute before accessing the
item at a provided index and returns `null` it the index is out of range
- when updating `LiveNodeList` (as part of accessing the `item` method)
and the new `length` is shorter then the current one, any references on
indexes following the index starting from `length` are `delete`d, and
`null` is returned instead of `undefined`
- added some exports to the `lib/dom.js` module to enable testing

fixes #499
karfau added a commit that referenced this pull request Jul 19, 2023
- `NodeList.item` now checks the `length` attribute before accessing the
item at a provided index and returns `null` it the index is out of range
- when updating `LiveNodeList` (as part of accessing the `item` method)
and the new `length` is shorter then the current one, any references on
indexes following the index starting from `length` are `delete`d, and
`null` is returned instead of `undefined`
- added some exports to the `lib/dom.js` module to enable testing

fixes #499
@karfau
Copy link
Member Author

karfau commented Jul 19, 2023

The fix landed in 0.7 (lts), 0.8 (latest) and 0.9 (next)

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.

NodeList.item() returns removed nodes
1 participant