mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Don't crash if ElementByIdMap already has an element
Let's simply reinsert the element respecting it's new position in the DOM tree, instead of crashing. Fixes regression in WPT tests caused by introducion of cache for getElementById().
This commit is contained in:
parent
9eca5febd1
commit
634f0c2469
Notes:
github-actions[bot]
2025-03-27 14:45:52 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 634f0c2469
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4118
Reviewed-by: https://github.com/gmta ✅
3 changed files with 1278 additions and 1 deletions
|
@ -17,7 +17,9 @@ void ElementByIdMap::add(FlyString const& element_id, Element& element)
|
|||
return !element.has_value();
|
||||
});
|
||||
|
||||
VERIFY(!elements_with_id.contains_slow(element));
|
||||
elements_with_id.remove_first_matching([&](auto const& another_element) {
|
||||
return &element == another_element.ptr();
|
||||
});
|
||||
elements_with_id.insert_before_matching(element, [&](auto& another_element) {
|
||||
return element.is_before(*another_element);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue