-
Notifications
You must be signed in to change notification settings - Fork 307
Trusted types attributes #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
Open
lukewarlow
wants to merge
3
commits into
whatwg:main
Choose a base branch
from
lukewarlow:trusted-types-attributes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Trusted types attributes #1268
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,9 +54,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]] | ||
|
@@ -6520,8 +6522,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); | ||
|
@@ -6946,6 +6948,14 @@ steps: | |
<a for=Attr>value</a>. | ||
</ol> | ||
|
||
<p>To <dfn>verify attribute value</dfn> given a {{TrustedType}} or string <var>value</var>, an | ||
<a>attribute</a> <var>attribute</var>, and an <a for=/>Element</a> <var>element</var>: | ||
|
||
<ol> | ||
<li><p>Return the result of calling <a abstract-op>get Trusted Types-compliant attribute value</a> | ||
given <var>attribute</var>, with <var>element</var>, and <var>value</var>. [[!TRUSTED-TYPES]] | ||
</ol> | ||
|
||
<hr> | ||
|
||
<div algorithm> | ||
|
@@ -6998,6 +7008,10 @@ 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 | ||
<a lt="verify attribute value">verifying an attribute value</a> given <var>attr</var>'s | ||
<a for=Attr>value</a>, <var>attr</var>, and <var>element</var>. | ||
|
||
<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}}. | ||
|
||
|
@@ -7013,6 +7027,8 @@ string <var>namespace</var> (default null):</p> | |
|
||
<li><p>Otherwise, <a lt="append an attribute">append</a> <var>attr</var> to <var>element</var>. | ||
|
||
<li><p>Set <var>attr</var>'s <a for=Attr>value</a> to <var>verifiedValue</var>. | ||
|
||
<li><p>Return <var>oldAttr</var>. | ||
</ol> | ||
</div> | ||
|
@@ -7294,14 +7310,26 @@ method steps are: | |
<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, then set <var>attribute</var> to 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>. | ||
Comment on lines
+7314
to
+7316
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. Is the idea here to create a dummy attribute that you don't append in order to calculate the verified value? Why is that done this way? This is quite confusing to read through. |
||
|
||
<li><p>Let <var>verifiedValue</var> be the result of | ||
<a lt="verify attribute value">verifying an attribute value</a> given <var>value</var>, | ||
<var>attribute</var>, and <a>this</a>. | ||
|
||
<li><p>Set <var>attribute</var> to 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. | ||
|
||
<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 | ||
|
@@ -7312,8 +7340,32 @@ method steps are: | |
<li><p>Let <var>namespace</var>, <var>prefix</var>, and <var>localName</var> be the result of | ||
passing <var>namespace</var> and <var>qualifiedName</var> to <a>validate and extract</a>. | ||
|
||
<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>attribute</var> be the result of | ||
<a lt="get an attribute by namespace and local name">getting an attribute</a> given | ||
<var>namespace</var>, <var>localName</var>, and <var>element</var>. | ||
|
||
<li><p>If <var>attribute</var> is null, then set attribute to an <a>attribute</a> whose | ||
<a for=Attr>namespace</a> is <var>namespace</var>, <a for=Attr>namespace prefix</a> is | ||
<var>prefix</var>, <a for=Attr>local name</a> is <var>localName</var>, <a for=Attr>value</a> is | ||
<var>value</var>, and <a for=Node>node document</a> is <var>element</var>'s | ||
<a for=Node>node document</a>. | ||
|
||
<li><p>Let <var>verifiedValue</var> be the result of | ||
<a lt="verify attribute value">verifying an attribute value</a> given <var>value</var>, | ||
<var>attribute</var>, and <var>element</var>. | ||
|
||
<li><p>Set <var>attribute</var> to the result of | ||
<a lt="get an attribute by namespace and local name">getting an attribute</a> given | ||
<var>namespace</var>, <var>localName</var>, and <var>element</var>. | ||
|
||
<li><p>If <var>attribute</var> is null, create an <a>attribute</a> whose <a for=Attr>namespace</a> | ||
is <var>namespace</var>, <a for=Attr>namespace prefix</a> is <var>prefix</var>, | ||
<a for=Attr>local name</a> is <var>localName</var>, <a for=Attr>value</a> is | ||
<var>verifiedValue</var>, and <a for=Node>node document</a> is <var>element</var>'s | ||
<a for=Node>node document</a>, then <a lt="append an attribute">append</a> this <a>attribute</a> to | ||
<var>element</var>, and then return. | ||
|
||
<li><p><a lt="change an attribute">Change</a> <var>attribute</var> to <var>verifiedValue</var>. | ||
</ol> | ||
|
||
<p>The | ||
|
@@ -7891,7 +7943,24 @@ 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>originalElement</var> be <var>attribute</var>'s <a for=Attr>element</a>. | ||
|
||
<li><p>Let <var>verifiedValue</var> be the result of | ||
<a lt="verify attribute value">verifying an attribute value</a> given <var>value</var>, | ||
<var>attribute</var>, and <a>this</a>. | ||
|
||
<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>originalElement</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.
Show resolved
Hide resolved
lukewarlow marked this conversation as resolved.
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> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although why do we even have this algorithm as it directly calls into the Trusted Types algorithm.