Bug 1838713 [wpt PR 40573] - Add part caching and ordering to DOM Parts, a=testonly

Automatic update from web-platform-tests
Add part caching and ordering to DOM Parts

Previously, parts were added to the list, and returned, in the order
they were constructed for a given root. Now, that list is stored as
an unsorted list, and when `getParts()` is called, a cached, sorted
list is returned.

NOTE: This CL does not add cache invalidation code where needed, so
moving nodes around in the DOM tree will not invalidate the cache.
Cache invalidation will be added and tested in a subsequent CL.

Bug: 1453291
Change-Id: I542b07520002202bfdc31d4341dca6cbffdc8b5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4616676
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1159056}

--

wpt-commits: 0868cb809d40d179379ad406c7da9c07a69429d9
wpt-pr: 40573
This commit is contained in:
Mason Freed 2023-06-19 20:24:28 +00:00 коммит произвёл moz-wptsync-bot
Родитель 4bff840c18
Коммит 0683eb6725
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -46,9 +46,14 @@ test(() => {
assert_equals(root.getParts().length,2);
assert_equals(root.getParts()[1],childNodePart);
const nodeBefore = target.previousSibling || target.parentNode;
const nodePartBefore = new NodePart(root,nodeBefore);
assert_equals(root.getParts().length,3,'getParts() for the root should now have this nodePart');
assert_array_equals(root.getParts(),[nodePartBefore,nodePart,childNodePart],'getParts() should return nodes in tree order');
const nodePart2 = new NodePart(childNodePart,target.children[2]);
assert_equals(nodePart2.root,childNodePart);
assert_equals(root.getParts().length,2,'getParts() for the root DocumentPartRoot shouldn\'t change');
assert_equals(root.getParts().length,3,'getParts() for the root DocumentPartRoot shouldn\'t change');
assert_equals(childNodePart.getParts().length,1);
assert_equals(childNodePart.getParts()[0],nodePart2);
}, 'Basic imperative DOM Parts object construction');