You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This behavior is correct: childNodes is a "live" NodeList, and changing the children is reflected immediately in the list. Which also means the current i now points to what would have been the next child, thus when the loop advances it skips an item.
Javascript implements it that way. Does PHP really want to be different about it? https://jsfiddle.net/54hoLzqv/
(keep in mind that it's the console output which shows items 1,2,3, while the document had 3 removed and so ends up with items 1,2,4)
Same for attributes, which is also a live NodeList.
Obligatory "this behavior has existed for a really long time so is there a good enough reason to change it now?"
The list is live, so upon cache invalidation we should rewalk the tree
to sync the index again with the node list. We keep the legacy behaviour
for the old DOM classes.
Description
The following code:
https://3v4l.org/TJLvF
Resulted in this output:
But I expected this output instead:
Source: nielsdos#93 (comment)
Credits to @veewee. Similar issue exists for attributes.
PHP Version
Since always
Operating System
No response
The text was updated successfully, but these errors were encountered: