Skip to content

Commit 6702593

Browse files
committed
Rewrote DOM integration, adding an expliting entry point algorithm to
call from DOM. whatwg/dom#789 Closes #401.
1 parent 4f94c5b commit 6702593

File tree

1 file changed

+14
-72
lines changed

1 file changed

+14
-72
lines changed

spec/index.bs

Lines changed: 14 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,18 +1091,6 @@ Given a {{TrustedType}} type (|expectedType|), a [=realm/global object=] (|globa
10911091

10921092
Given an {{HTMLScriptElement}} (|script|), this algorithm performs the following steps:
10931093

1094-
1. If |script| does not have a <{script/src}> content attribute, set its {{HTMLScriptElement/[[ScriptURL]]}} internal slot value to `null`.
1095-
1096-
1. Otherwise, if |script|'s {{HTMLScriptElement/[[ScriptURL]]}} internal slot value is not equal to its <{script/src}> attribute value,
1097-
set |script|'s {{HTMLScriptElement/[[ScriptURL]]}} to the result of executing [$Get Trusted Type compliant string$], with the following arguments:
1098-
* {{TrustedScriptURL}} as |expectedType|,
1099-
* |script|'s {{Document}}'s [=relevant global object=] as |global|,
1100-
* |script|'s <{script/src}> attribute value as |input|,
1101-
* `HTMLScriptElement src` as |sink|,
1102-
* `'script'` as |sinkGroup|.
1103-
1104-
If the algorithm threw an error, rethrow the error and abort further steps.
1105-
11061094
1. If |script|'s {{HTMLScriptElement/[[ScriptText]]}} internal slot value is not equal to its [=child text content=],
11071095
set |script|'s {{HTMLScriptElement/[[ScriptText]]}} to the result of executing [$Get Trusted Type compliant string$], with the following arguments:
11081096
* {{TrustedScriptURL}} as |expectedType|,
@@ -1113,6 +1101,20 @@ Given an {{HTMLScriptElement}} (|script|), this algorithm performs the following
11131101

11141102
If the algorithm threw an error, rethrow the error.
11151103

1104+
## <dfn-abstract-op export>Validate attribute mutation</dfn> ## {#validate-attribute-mutation}
1105+
Given {{Attr}} |attribute|, {{Element}} |element| and {{TrustedType}} or a string |newValue|, this algorithm performs the following steps:
1106+
1107+
1. If |element| has an <a spec="webidl" lt="attribute">IDL attribute</a> that [=reflects=] a content attribute with |attribute|'s [=Attr/local name=], let |idlAttribute| be that IDL attribute. Otherwise, return stringified |newValue|.
1108+
1. If {{StringContext}} IDL extended attribute does not appears on |idlAttribute|, return stringified |newValue|.
1109+
1. Set |value| to the result of executing [$Get Trusted Type compliant string$] with the following arguments:
1110+
* {{StringContext}} identifier as |expectedType|
1111+
* |newValue| as |input|
1112+
* |element|'s <a>relevant global object</a> as |global|
1113+
* the result of [=concatenating=] the list &laquo; |element|'s [=Element/local name=], |attribute|'s |localName| &raquo; with `"."` as a |separator| as |sink|
1114+
* 'script' as |sinkGroup|
1115+
1116+
If the algorithm threw an error, rethrow the error.
1117+
11161118
# Integrations # {#integrations}
11171119

11181120
<pre class="idl">
@@ -1245,15 +1247,8 @@ partial interface Document {
12451247

12461248
#### Slots with trusted values #### {#slots-with-trusted-values}
12471249

1248-
Issue: Figure out if we can drop {{HTMLScriptElement/[[ScriptURL]]}} slot after IDL + DOM changes.
1249-
12501250
This document modifies {{HTMLScriptElement}}s. Each script has:
12511251

1252-
: <dfn for="HTMLScriptElement" lt="[[ScriptURL]]" attribute>`[[ScriptURL]]`</dfn> internal slot.
1253-
:: A string, containing the URL to execute the script from
1254-
that was set through a {{StringContext}} compliant sink. Equivalent to
1255-
{{HTMLScriptElement/src}} attribute value. Initially null.
1256-
12571252
: <dfn for="HTMLScriptElement" lt="[[ScriptText]]" attribute>`[[ScriptText]]`</dfn> internal slot.
12581253
:: A string, containing the body of the script to execute that was set
12591254
through a {{StringContext}} compliant sink. Equivalent to script's
@@ -1283,12 +1278,6 @@ On setting the {{HTMLElement/innerText}}, {{Node/textContent}} and {{HTMLScriptE
12831278
1. Set {{HTMLScriptElement/[[ScriptText]]}} internal slot value to the stringified attribute value.
12841279
1. Perform the usual attribute setter steps.
12851280

1286-
1287-
On setting the {{HTMLScriptElement/src}} IDL attribute, execute the following algorithm:
1288-
1289-
1. Set {{HTMLScriptElement/[[ScriptURL]]}} internal slot value to the stringified attribute value.
1290-
1. Perform the usual attribute setter steps.
1291-
12921281
#### Slot value verification #### {#slot-value-verification}
12931282

12941283
The first few steps of the [=prepare the script element=] algorithm are modified as follows:
@@ -1312,14 +1301,6 @@ The first few steps of the [=prepare the script element=] algorithm are modified
13121301
<li><p>Let <var>source text</var> be <var>el</var>'s <del><a id=script-processing-model:child-text-content href=https://dom.spec.whatwg.org/#concept-child-text-content data-x-internal=child-text-content>child text content</a>.</del> <ins>`[[ScriptText]]` internal slot value.</ins>
13131302
<li>...
13141303
</ol>
1315-
<p>In all subsequent steps, replace checks for <code>src</code> attribute existence with checks for non-null `[[ScriptURL]]` internal slot value, and replace references of <code>src</code> content attribute value with `[[ScriptURL]]` internal slot value. For example:
1316-
<ul>
1317-
<li>If <del><var>el</var> does not have a <code>src</a></code> content attribute</del><ins><var>el</var>'s `[[ScriptURL]]` internal slot value is null</ins>, and the <a id="script-processing-model:should-element's-inline-behavior-be-blocked-by-content-security-policy" href=https://w3c.github.io/webappsec-csp/#should-block-inline data-x-internal="should-element's-inline-behavior-be-blocked-by-content-security-policy">Should element's inline
1318-
behavior be blocked by Content Security Policy?</a> algorithm returns "<code>Blocked</code>" when given <var>el</var>, "<code>script</code>", and
1319-
<var>source text</var>, then return.
1320-
<li>If <var>el</var><ins>'s</ins> <del>has a <code>src</code> content attribute</del><ins>`[[ScriptURL]]` internal slot value is not null</ins>, then:
1321-
<li><p>Let <var ignore="">src</var> be the value of <var>el</var>'s <del><code>src</a></code> attribute</del><ins>`[[ScriptURL]]` internal slot</ins>.
1322-
</ul>
13231304

13241305
### Enforcement in element attributes ### {#enforcement-in-sinks}
13251306

@@ -1495,45 +1476,6 @@ On setting {{SVGAnimatedString/baseVal}}, the following steps are run:
14951476

14961477
Note: SVG does not have a complete script processing model <a href="https://github.com/w3c/svgwg/issues/196">yet</a>. Trusted Types assumes that the attribute and text body modification protections behave similarly to ones for HTML scripts outlined in [[#enforcement-in-scripts]].
14971478

1498-
## Integration with DOM ## {#integration-with-dom}
1499-
1500-
This document modifies the {{Element}} interface, adding <a>attribute validation steps</a>:
1501-
1502-
<p><ins>This and <a lt="other applicable specifications">other specifications</a> may define
1503-
<dfn export id=concept-element-attributes-validation-ext>attribute validation steps</dfn> for
1504-
<a for=/ spec=dom>elements</a>. The algorithm is passed <var>element</var>, <var>localName</var>,
1505-
<var>value</var>, and <var ignore>namespace</var>.</ins>
1506-
1507-
This document changes the <a spec="dom">handle attribute changes</a> algorithm, adding the following step at the beginning:
1508-
<ol>
1509-
<li><ins><p>Run the <a>attribute validation steps</a> with <var>element</var>,
1510-
<var>attribute</var>'s <a for=Attr>local name</a>, <var ignore>newValue</var> and
1511-
<var>attribute</var>'s <a for=Attr>namespace</a>. If this throws an exception, then
1512-
rethrow the exception and abort further steps.</ins>
1513-
</ol>
1514-
1515-
Additionally, this document changes the <a spec=dom>append</a> an attribute algorithm:
1516-
1517-
<p>To <dfn export id=concept-element-attributes-append lt="append an attribute">append</dfn> an
1518-
<a spec=dom>attribute</a> <var>attribute</var> to an <a spec=dom for="/">element</a> <var>element</var>
1519-
<ins>with a <var>value</var></ins>, run these steps:
1520-
1521-
<ol>
1522-
<li><p><a spec="dom">Handle attribute changes</a> for <var>attribute</var> with <var>element</var>, null, and
1523-
<del><var>attribute</var>'s <a for=Attr>value</a></del><ins><var>value</var></ins>.
1524-
1525-
<li><ins><p>Set <var>attribute</var>'s <a for=Attr>value</a> to <var>value</var>.</ins>
1526-
1527-
<li><p><a for=list>Append</a> <var>attribute</var> to <var>element</var>'s
1528-
<a for=Element>attribute list</a>.
1529-
<li><p>Set <var>attribute</var>'s <a for=Attr>element</a> to <var>element</var>.
1530-
</ol>
1531-
1532-
Callers of this algorithm are changed accordingly.
1533-
1534-
Issue: Remove when <a href="https://github.com/whatwg/dom/pull/809">DOM #809</a> is merged.
1535-
1536-
15371479
## Integration with DOM Parsing ## {#integration-with-dom-parsing}
15381480

15391481
This document modifies the following interfaces defined by [[DOM-Parsing]]:

0 commit comments

Comments
 (0)