Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent access to ElementInternals.shadowRoot for pre-existing shadow roots #5921

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-element"><code>Element</code></dfn> interface</li>
<li><dfn data-x="dom-Element-attachShadow" data-x-href="https://dom.spec.whatwg.org/#dom-element-attachshadow"><code>attachShadow()</code></dfn> method.</li>
<li>An element's <dfn data-x="concept-element-shadow-root" data-x-href="https://dom.spec.whatwg.org/#concept-element-shadow-root">shadow root</dfn></li>
<li>A <span data-x="concept-element-shadow-root">shadow root</span>'s <dfn data-x="concept-available-to-element-internals" data-x-href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals">available to element internals</dfn> flag</li>
<li>The <dfn data-x="dom-retarget" data-x-href="https://dom.spec.whatwg.org/#retarget">retargeting algorithm</dfn></li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-node"><code>Node</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-nodelist"><code>NodeList</code></dfn> interface</li>
Expand Down Expand Up @@ -66965,6 +66966,8 @@ interface <dfn>ElementInternals</dfn> {
boolean <span data-x="dom-ElementInternals-reportValidity">reportValidity</span>();

readonly attribute <span>NodeList</span> <span data-x="dom-ElementInternals-labels">labels</span>;

readonly attribute <code>ShadowRoot</code>? <span data-x="dom-ElementInternals-shadowRoot">shadowRoot</span>;
};

dictionary <dfn>ValidityStateFlags</dfn> {
Expand Down Expand Up @@ -67051,6 +67054,12 @@ dictionary <dfn>ValidityStateFlags</dfn> {
<dd><p>Returns a <code>NodeList</code> of all the <code>label</code> elements that
<var>internals</var>'s <span data-x="internals-target">target element</span> is associated
with.</p></dd>

<dt><var>internals</var> . <code data-x="dom-ElementInternals-shadowRoot">shadowRoot</code></dt>
<dd><p>Returns the <code>ShadowRoot</code> for <var>internals</var>'s
<span data-x="internals-target">target element</span>, if the
<span data-x="internals-target">target element</span> is a <span>shadow host</span>, or null
otherwise.</p></dd>
</dl>

<p>Each <code>ElementInternals</code> has a <dfn data-x="internals-target">target element</dfn>,
Expand Down Expand Up @@ -67091,6 +67100,28 @@ dictionary <dfn>ValidityStateFlags</dfn> {
<span data-x="internals-target">targeting</span> <var>element</var>, and return it.</p></li>
</ol>

<p>The <dfn><code data-x="dom-ElementInternals-shadowRoot">shadowRoot</code></dfn> attribute on
the <code>ElementInternals</code> object must return the result of running the <span>get
ElementInternals shadowRoot</span> algorithm with the <code>ElementInternals</code> object as
the argument.</p>

<p>The <dfn data-export="">get ElementInternals shadowRoot</dfn> algorithm, given an <code>ElementInternals</code> object
<var>internals</var>, is as follows:</p>

<ol>
<li><p>Let <var>target</var> be <var>internals</var>'s <span data-x="internals-target">target element</span>.</p></li>

<li><p>If <var>target</var> is not a <span>shadow host</span>, return null.</p></li>

<li><p>Let <var>host</var> be <var>target</var>'s <code>ShadowRoot</code>.</p></li>

<li><p>If <var>host</var>'s <span data-x="concept-available-to-element-internals">available to element internals</span>
property is false, and <var>host</var>'s <span data-x="concept-is-declarative-shadow-root">is declarative shadow root</span>
property is also false, then return null.</p></li>

<li><p>Return <var>host</var>.</p></li>
</ol>

<hr>

<p>Each <span>form-associated custom element</span> has <dfn
Expand Down