Skip to content

Commit 436bc9e

Browse files
committed
Rewrite metadata functions
- getAttributeType and getPropertyType now use lookup tables.
1 parent 51d9e37 commit 436bc9e

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

spec/index.bs

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -671,15 +671,29 @@ initially empty.
671671

672672
1. Set |localName| to |tagName| in [=ASCII lowercase=].
673673
1. If |elementNs| is an empty string, set |elementNs| to [=HTML namespace=].
674+
1. If |property| starts with "on", then return {{TrustedScript}}.
674675
1. Let |interface| be the [=element interface=] for |localName| and |elementNs|.
675-
1. If |interface| has an IDL <a spec="webidl">attribute</a> member which identifier is |attribute|, and
676-
{{StringContext}} IDL extended attribute appears on that attribute, return
677-
stringified {{StringContext}}'s identifier and abort further steps.
678-
679-
Note: This also takes into account all members of [=interface mixins=] that
680-
|interface| [=includes=].
681-
682-
1. Return null.
676+
1. Let |expectedType| be null.
677+
1. Find the row in the following table, where the first column is "*" or |interface|'s name, and |property| is in the second column.
678+
If a matching row is found, set |expectedType| to the value of the third column.
679+
680+
<table>
681+
<thead>
682+
<tr><th>Element<th>Property name<th>TrustedType
683+
<tbody>
684+
<tr><td>{{HTMLEmbedElement}}<td>"src"<td>{{TrustedScriptURL}}
685+
<tr><td>{{HTMLIFrameElement}}<td>"srcdoc"<td>{{TrustedHTML}}
686+
<tr><td>{{HTMLObjectElement}}<td>"codebase"<td>{{TrustedScriptURL}}
687+
<tr><td>{{HTMLObjectElement}}<td>"data"<td>{{TrustedScriptURL}}
688+
<tr><td>{{HTMLScriptElement}}<td>"innerText"<td>{{TrustedScript}}
689+
<tr><td>{{HTMLScriptElement}}<td>"src"<td>{{TrustedScriptURL}}
690+
<tr><td>{{HTMLScriptElement}}<td>"text"<td>{{TrustedScript}}
691+
<tr><td>{{HTMLScriptElement}}<td>"textContent"<td>{{TrustedScript}}
692+
<tr><td>"*"<td>"innerHTML"<td>{{TrustedHTML}}
693+
<tr><td>"*"<td>"outerHTML"<td>{{TrustedHTML}}
694+
</tbody>
695+
</table>
696+
1. Return |expectedType|.
683697

684698
<div class="example" id="get-property-type-example">
685699
<xmp highlight="js">
@@ -698,15 +712,28 @@ initially empty.
698712

699713
1. Set |localName| to |tagName| in [=ASCII lowercase=].
700714
1. Set |attribute| to |attribute| in [=ASCII lowercase=].
715+
1. If |attribute| starts with "on", then return {{TrustedScript}}.
701716
1. If |elementNs| is an empty string, set |elementNs| to [=HTML namespace=].
702717
1. If |attrNs| is an empty string, set |attrNs| to null.
703718
1. Let |interface| be the [=element interface=] for |localName| and |elementNs|.
704-
1. If |interface| does not have an IDL <a spec="webidl">attribute</a> that [=reflects=] a content attribute with
705-
|localName| local name and |attrNs| namespace,
706-
return undefined and abort further steps. Otherwise, let |idlAttribute| be that IDL <a spec="webidl">attribute</a>.
707-
1. If {{StringContext}} IDL extended attribute appears on |idlAttribute|, return
708-
stringified {{StringContext}}'s identifier and abort further steps.
709-
1. Return null.
719+
1. Let |expectedType| be null.
720+
1. Find the row in the following table, where |interface|'s name is in the first column, and |attribute|'s <a for="Attr">namespace</a> and <a for="Attr">local name</a> match the values in the second and third column, respectively.
721+
If a matching row is found, set |expectedType| to the value of the fourth.
722+
723+
<table>
724+
<thead>
725+
<tr><th>Element<th>Attribute namespace<th>Attribute local name<th>TrustedType
726+
<tbody>
727+
<tr><td>{{HTMLIFrameElement}}<td>null<td>"srcdoc"<td>{{TrustedHTML}}
728+
<tr><td>{{HTMLEmbedElement}}<td>null<td>"src"<td>{{TrustedScriptURL}}
729+
<tr><td>{{HTMLScriptElement}}<td>null<td>"src"<td>{{TrustedScriptURL}}
730+
<tr><td>{{HTMLObjectElement}}<td>null<td>"data"<td>{{TrustedScriptURL}}
731+
<tr><td>{{HTMLObjectElement}}<td>null<td>"codebase"<td>{{TrustedScriptURL}}
732+
<tr><td>{{SVGScriptElement}}<td>null<td>"href"<td>{{TrustedScriptURL}}
733+
<tr><td>{{SVGScriptElement}}<td><a>XLink namespace</a><td>"href"<td>{{TrustedScriptURL}}
734+
</tbody>
735+
</table>
736+
1. Return |expectedType|.
710737

711738
<div class="example" id="get-attribute-type-example">
712739
<xmp highlight="js">

0 commit comments

Comments
 (0)