github web-platform-tests/wpt merge_pr_46832

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
15 months ago

Text Fragments: Correctly find text fragments if there are DOM changes during page load.

Before this patch, the first call to Document::ScrollToRef() would attempt to find all text directives in the document, and, if found, highlight + scroll to them. Then, it would clear the list of uninvoked directives.

However, ScrollToRef() is called multiple times during a page load, and the DOM can change (e.g. if DOMContentLoaded does some changes).

This patch fixes this by only removing the text directives which were found in the document from the list of uninvoked directives.
This way, subsequent calls to ScrollToRef() would ensure that all text directives are highlighted, and the first text directive is scrolled to.
Additionally, all remaining uninvoked text directives at the end of a page load (ie. text directives that are not on the page) are cleared.

A test was added as well.

Differential Revision: https://phabricator.services.mozilla.com/D211260

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1898321
gecko-commit: 986a6317351d0690fa5f059b2a00a8248d990fe9
gecko-reviewers: farre, dom-core

Don't miss a new wpt release

NewReleases is sending notifications on new releases.