Closed Bug 1627596 Opened 5 years ago Closed 5 years ago

[wpt-sync] Sync PR 22709 - Adds ability to clear out assigned nodes to slot when slot is removed from shadow root.

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 22709 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/22709
Details from upstream follow.

Yu Han <yuzhehan@chromium.org> wrote:

Adds ability to clear out assigned nodes to slot when slot is removed from shadow root.

Prior to this CL, when a slot with imperatively assigned nodes is
removed from the its shadow root, assignment recalc is deferred until
an API (Slot.assignedNodes, Node.assignedSlot) or a LifeCycleUpdate
triggers the recalc. If no assignment recalc is triggered and the
slot is added back to its original shadow root, its imperatively
assigned nodes will reappear. This is an unwanted side effect
because if an assignment recalc is trigger before slot is added back,
its assigned nodes will be cleared.

This CL fixes this side effect by clearing a slot's imperatively
assigned nodes whenever it's removed from its parent node. Thus,
regardless of whether a recalc is trigger before the slot is added back
or not, the end result is that the slot's assigned nodes are empty.

Note: With this CL, even moving the slot inside it's shadow root will
clear out its imperatively assigned nodes. See example:
host
---sr
--s1
--s2
--c1

s2.assign([c1]);
sr.insertBefore(s2, s1);
assert_array_equals(s2.assignedNodes(), []);

I believe this is correct behavior. The output should be the same as
removed = sr.removeChild(s2)
sr.appendChild(removed);

The behavior is consistent for a slot inside a shadow root with
manual slot assignment. Whether the slot is moved or removed/appended
inside its containing shadow root, the result is its assigned nodes
are cleared.

Bug:869308
Change-Id: Ie1247684b77d5c4b8e5f113421807c0c187224f0

Reviewed-on: https://chromium-review.googlesource.com/2135371
WPT-Export-Revision: 1fae0e5c9532117499e9d2166188d076db48ddcf

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Test result changes from PR not available.
Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b299d13d01d5 [wpt PR 22709] - Adds ability to clear out assigned nodes to slot when slot is removed from shadow root., a=testonly https://hg.mozilla.org/integration/autoland/rev/c08f0a2a070e [wpt PR 22709] - Update wpt metadata, a=testonly
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77
You need to log in before you can comment on or make changes to this bug.