RESOLVED INVALID197868
getElementsByClassName and set outerHTML: later elements in array are not reachable
https://bugs.webkit.org/show_bug.cgi?id=197868
Summary getElementsByClassName and set outerHTML: later elements in array are not rea...
alvin_signups
Reported 2019-05-13 20:22:49 PDT
Created attachment 369817 [details] Demo of the bug While (a) iterating on a group of elements from document.getElementsByClassName and (b) setting outerHTML for each element, latter elements become inaccessible in an ascending for-loop. This is only triggered for outerHTML, not for innerHTML. Current workaround - Iterate in descending order or use innerHTML instead.
Attachments
Demo of the bug (1.76 KB, text/html)
2019-05-13 20:22 PDT, alvin_signups
no flags
Alexey Proskuryakov
Comment 1 2019-05-15 14:17:44 PDT
This test appears to have identical results in Safari, Firefox and Chrome. Could you please clarify what the expected behavior is, and why it is different from what browsers do? ------------------------------ Iterating from end of array substituted substituted substituted substituted Iterating from start of array substituted B substituted D
alvin_signups
Comment 2 2019-05-15 22:53:56 PDT
Hi Alexey, thanks for looking into this. I did test this against other browsers, so I understand what you mean. Someone from the Chromium team explained that getElementsByClassName returns a live node collection. It was quite odd behaviour to me, but I understand that is to spec. I think you can close this. Thanks for your time! Alvin
Note You need to log in before you can comment on or make changes to this bug.