- 
                Notifications
    You must be signed in to change notification settings 
- Fork 318
Integrate Trusted Types enforcement into attribute handling #1268
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
aa3fe7e
              526f422
              00d0eaa
              f5e3984
              df2bccd
              eb1b546
              1e3cef8
              6fe40a3
              78773d9
              f3148ed
              383d39c
              2075acd
              1ff8aaa
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -50,9 +50,11 @@ spec:html; type:element | |
| <p>This specification depends on the Infra Standard. [[!INFRA]] | ||
|  | ||
| <p>Some of the terms used in this specification are defined in <cite>Encoding</cite>, | ||
| <cite>Selectors</cite>, <cite>Web IDL</cite>, <cite>XML</cite>, and <cite>Namespaces in XML</cite>. | ||
| <cite>Selectors</cite>, <cite>Trusted Types</cite>, <cite>Web IDL</cite>, <cite>XML</cite>, and | ||
| <cite>Namespaces in XML</cite>. | ||
| [[!ENCODING]] | ||
| [[!SELECTORS4]] | ||
| [[!TRUSTED-TYPES]] | ||
| [[!WEBIDL]] | ||
| [[!XML]] | ||
| [[!XML-NAMES]] | ||
|  | @@ -6633,8 +6635,8 @@ interface Element : Node { | |
| sequence<DOMString> getAttributeNames(); | ||
| DOMString? getAttribute(DOMString qualifiedName); | ||
| DOMString? getAttributeNS(DOMString? namespace, DOMString localName); | ||
| [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value); | ||
| [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value); | ||
| [CEReactions] undefined setAttribute(DOMString qualifiedName, (TrustedType or DOMString) value); | ||
| [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, (TrustedType or DOMString) value); | ||
| [CEReactions] undefined removeAttribute(DOMString qualifiedName); | ||
| [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName); | ||
| [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force); | ||
|  | @@ -7115,6 +7117,11 @@ string <var>namespace</var> (default null):</p> | |
| <a for=/>attribute</a> <var>attr</var> and an <a for=/>element</a> <var>element</var>: | ||
|  | ||
| <ol> | ||
| <li><p>Let <var>verifiedValue</var> be the result of calling <a abstract-op>get | ||
| Trusted Types-compliant attribute value</a> with <var>attr</var>'s <a for=Attr>local name</a>, | ||
| <var>attr</var>'s <a for=Attr>namespace</a>, <var>element</var>, and <var>attr</var>'s | ||
| <a for=Attr>value</a>. [[!TRUSTED-TYPES]] | ||
|  | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit nitpicking, but I think I'd prefer still that passing existing attribute node here would be no-op. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...but I can also live with this proposed algorithm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After our discussion I'm going to keep it how it is, tests to ensure Firefox behaviour fails is added here web-platform-tests/wpt#55762 | ||
| <li><p>If <var>attr</var>'s <a for=Attr>element</a> is neither null nor <var>element</var>, | ||
| <a>throw</a> an "{{InUseAttributeError!!exception}}" {{DOMException}}. | ||
|  | ||
|  | @@ -7125,6 +7132,8 @@ string <var>namespace</var> (default null):</p> | |
|  | ||
| <li><p>If <var>oldAttr</var> is <var>attr</var>, return <var>attr</var>. | ||
|         
                  lukewarlow marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| <li><p>Set <var>attr</var>'s <a for=Attr>value</a> to <var>verifiedValue</var>. | ||
|  | ||
|         
                  lukewarlow marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| <li><p>If <var>oldAttr</var> is non-null, then <a lt="replace an attribute">replace</a> | ||
| <var>oldAttr</var> with <var>attr</var>. | ||
|  | ||
|  | @@ -7414,17 +7423,21 @@ method steps are: | |
| <a>HTML document</a>, then set <var>qualifiedName</var> to <var>qualifiedName</var> in | ||
| <a>ASCII lowercase</a>. | ||
|  | ||
| <li><p>Let <var>verifiedValue</var> be the result of calling <a abstract-op>get | ||
| Trusted Types-compliant attribute value</a> with <var>qualifiedName</var>, null, <a>this</a>, and | ||
| <var>value</var>. [[!TRUSTED-TYPES]] | ||
|  | ||
| <li><p>Let <var>attribute</var> be the first <a>attribute</a> in <a>this</a>'s | ||
| <a for=Element>attribute list</a> whose <a for=Attr>qualified name</a> is <var>qualifiedName</var>, | ||
| and null otherwise. | ||
| <!-- This is step 2 of "get an attribute by name", modified as appropriate --> | ||
|  | ||
| <li><p>If <var>attribute</var> is null, create an <a>attribute</a> whose | ||
| <a for=Attr>local name</a> is <var>qualifiedName</var>, <a for=Attr>value</a> is | ||
| <var>value</var>, and <a for=Node>node document</a> is <a>this</a>'s <a for=Node>node document</a>, | ||
| then <a lt="append an attribute">append</a> this <a>attribute</a> to <a>this</a>, and then return. | ||
| <var>verifiedValue</var>, and <a for=Node>node document</a> is <a>this</a>'s | ||
| <a for=Node>node document</a>, then <a lt="append an attribute">append</a> this <a>attribute</a> | ||
| to <a>this</a>, and then return. | ||
|  | ||
| <li><p><a lt="change an attribute">Change</a> <var>attribute</var> to <var>value</var>. | ||
| <li><p><a lt="change an attribute">Change</a> <var>attribute</var> to <var>verifiedValue</var>. | ||
| </ol> | ||
|  | ||
| <p>The | ||
|  | @@ -7436,8 +7449,12 @@ method steps are: | |
| [=validate and extract|validating and extracting=] <var>namespace</var> and | ||
| <var>qualifiedName</var> given "<code>element</code>". | ||
|  | ||
| <li><p><a>Set an attribute value</a> for <a>this</a> using <var>localName</var>, <var>value</var>, | ||
| and also <var>prefix</var> and <var>namespace</var>. | ||
| <li><p>Let <var>verifiedValue</var> be the result of calling <a abstract-op>get | ||
| Trusted Types-compliant attribute value</a> with <var>localName</var>, <var>namespace</var>, | ||
| <var>element</var>, and <var>value</var>. [[!TRUSTED-TYPES]] | ||
|         
                  lukewarlow marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| <li><p><a>Set an attribute value</a> for <a>this</a> using <var>localName</var>, | ||
| <var>verifiedValue</var>, and also <var>prefix</var> and <var>namespace</var>. | ||
| </ol> | ||
|  | ||
| <p>The | ||
|  | @@ -8028,7 +8045,25 @@ string <var>value</var>, run these steps: | |
| <li><p>If <var>attribute</var>'s <a for=Attr>element</a> is null, then set <var>attribute</var>'s | ||
| <a for=Attr>value</a> to <var>value</var>. | ||
|  | ||
| <li><p>Otherwise, <a lt="change an attribute">change</a> <var>attribute</var> to <var>value</var>. | ||
| <li> | ||
| <p>Otherwise: | ||
|  | ||
| <ol> | ||
| <li><p>Let <var>element</var> be <var>attribute</var>'s <a for=Attr>element</a>. | ||
|  | ||
| <li><p>Let <var>verifiedValue</var> be the result of calling <a abstract-op>get | ||
| Trusted Types-compliant attribute value</a> with <var>attribute</var>'s | ||
| <a for=Attr>local name</a>, <var>attribute</var>'s <a for=Attr>namespace</a>, | ||
| <var>element</var>, and <var>value</var>. [[!TRUSTED-TYPES]] | ||
|  | ||
| <li><p>If <var>attribute</var>'s <a for=Attr>element</a> is null, then set <var>attribute</var>'s | ||
| <a for=Attr>value</a> to <var>verifiedValue</var>, and return. | ||
|  | ||
| <li><p>If <var>attribute</var>'s <a for=Attr>element</a> is not <var>element</var>, then | ||
| return. | ||
|          | ||
|  | ||
| <li><p><a lt="change an attribute">Change</a> <var>attribute</var> to <var>verifiedValue</var>. | ||
|         
                  lukewarlow marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved         
                  lukewarlow marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| </ol> | ||
| </ol> | ||
|  | ||
| <p>The {{Attr/value}} setter steps are to <a>set an existing attribute value</a> with <a>this</a> | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.