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 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); Bug: 869308 Change-Id: Ie1247684b77d5c4b8e5f113421807c0c187224f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135371Reviewed-by:Mason Freed <masonfreed@chromium.org> Commit-Queue: Yu Han <yuzhehan@chromium.org> Cr-Commit-Position: refs/heads/master@{#758334}
Showing
Please register or sign in to comment