Skip to content

Commit

Permalink
Call SetNeedsAssignmentRecalc in HTMLSlotElement::ChildrenChanged
Browse files Browse the repository at this point in the history
(cherry picked from commit 3f7c402)

Bug: 1184357
Change-Id: Id9e804e5762ac6c40ba1be0620401d219d6f4d90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2734104
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Mason Freed <masonfreed@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#859652}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2734255
Reviewed-by: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/4435@{#5}
Cr-Branched-From: f3c257e-refs/heads/master@{#859168}
  • Loading branch information
josepharhar authored and Krishna Govind committed Mar 4, 2021
1 parent e5cd748 commit 7610baf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions third_party/blink/renderer/core/html/html_slot_element.cc
Expand Up @@ -758,6 +758,12 @@ bool HTMLSlotElement::HasAssignedNodesSlow() const {
return assignment.FindHostChildBySlotName(GetName());
}

void HTMLSlotElement::ChildrenChanged(const ChildrenChange& change) {
Element::ChildrenChanged(change);
if (SupportsAssignment())
SetShadowRootNeedsAssignmentRecalc();
}

void HTMLSlotElement::Trace(Visitor* visitor) const {
visitor->Trace(assigned_nodes_);
visitor->Trace(flat_tree_children_);
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/renderer/core/html/html_slot_element.h
Expand Up @@ -125,6 +125,8 @@ class CORE_EXPORT HTMLSlotElement final : public HTMLElement {
InsertionNotificationRequest InsertedInto(ContainerNode&) final;
void RemovedFrom(ContainerNode&) final;

void ChildrenChanged(const ChildrenChange&) override;

void EnqueueSlotChangeEvent();

bool HasSlotableChild() const;
Expand Down
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<div>
<p>there should be more text below this</p>
<p>PASS if this text is visible</p>
</div>
23 changes: 23 additions & 0 deletions third_party/blink/web_tests/external/wpt/dom/slot-recalc.html
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1184357">

<link rel="match" href="/dom/slot-recalc-ref.html">

<body>
<script>
const host = document.createElement('div');
document.body.appendChild(host);
const root = host.attachShadow({mode: 'open'});

const slot = document.createElement('slot');
slot.innerHTML = `<p>there should be more text below this</p>`;
root.appendChild(slot);

onload = () => {
const shouldBeVisible = document.createElement('p');
shouldBeVisible.textContent = 'PASS if this text is visible';
slot.appendChild(shouldBeVisible);
};
</script>

0 comments on commit 7610baf

Please sign in to comment.