Skip to content

Commit 7e04bae

Browse files
committed
Fix createElement and importNode
1 parent 9137b50 commit 7e04bae

File tree

1 file changed

+86
-24
lines changed

1 file changed

+86
-24
lines changed

dom.bs

+86-24
Original file line numberDiff line numberDiff line change
@@ -5208,7 +5208,7 @@ interface Document : Node {
52085208
[NewObject] Comment createComment(DOMString data);
52095209
[NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
52105210

5211-
[CEReactions, NewObject] Node importNode(Node node, optional boolean subtree = false);
5211+
[CEReactions, NewObject] Node importNode(Node node, optional (boolean or ImportNodeOptions) options = false);
52125212
[CEReactions] Node adoptNode(Node node);
52135213

52145214
[NewObject] Attr createAttribute(DOMString localName);
@@ -5227,8 +5227,14 @@ interface Document : Node {
52275227
interface XMLDocument : Document {};
52285228

52295229
dictionary ElementCreationOptions {
5230+
CustomElementRegistry customElements;
52305231
DOMString is;
52315232
};
5233+
5234+
dictionary ImportNodeOptions {
5235+
CustomElementRegistry customElements;
5236+
selfOnly = false;
5237+
}
52325238
</pre>
52335239

52345240
<p>{{Document}} <a for=/>nodes</a> are simply
@@ -5450,12 +5456,19 @@ method steps are to return the <a>list of elements with class names <var>classNa
54505456
<var>document</var> is an <a>HTML document</a> or <var>document</var>'s
54515457
<a for=Document>content type</a> is "<code>application/xhtml+xml</code>"; otherwise null.
54525458

5453-
<p>If <var>localName</var> does not match the <code><a type>Name</a></code> production an
5454-
"{{InvalidCharacterError!!exception}}" {{DOMException}} will be thrown.
5459+
<p>When supplied, <var>options</var>'s {{ElementCreationOptions/customElements}} can be used to
5460+
set the {{CustomElementRegistry}}.
54555461

54565462
<p>When supplied, <var>options</var>'s {{ElementCreationOptions/is}} can be used to create a
54575463
<a>customized built-in element</a>.
54585464

5465+
<p>If <var>localName</var> does not match the <code><a type>Name</a></code> production an
5466+
"{{InvalidCharacterError!!exception}}" {{DOMException}} will be thrown.
5467+
5468+
<p>When both <var>options</var>'s {{ElementCreationOptions/customElements}} and
5469+
<var>options</var>'s {{ElementCreationOptions/is}} are supplied, a
5470+
"{{NotSupportedError!!exception}}" {{DOMException}} will be thrown.
5471+
54595472
<dt><code><var>element</var> = <var>document</var> . <a method for=Document lt=createElementNS()>createElementNS(namespace, qualifiedName [, options])</a></code>
54605473

54615474
<dd>
@@ -5464,6 +5477,12 @@ method steps are to return the <a>list of elements with class names <var>classNa
54645477
<var>qualifiedName</var> or null. Its <a for=Element>local name</a> will be everything after
54655478
U+003A (:) in <var>qualifiedName</var> or <var>qualifiedName</var>.
54665479

5480+
<p>When supplied, <var>options</var>'s {{ElementCreationOptions/customElements}} can be used to
5481+
set the {{CustomElementRegistry}}.
5482+
5483+
<p>When supplied, <var>options</var>'s {{ElementCreationOptions/is}} can be used to create a
5484+
<a>customized built-in element</a>.
5485+
54675486
<p>If <var>qualifiedName</var> does not match the <code><a type>QName</a></code> production an
54685487
"{{InvalidCharacterError!!exception}}" {{DOMException}} will be thrown.
54695488

@@ -5486,8 +5505,9 @@ method steps are to return the <a>list of elements with class names <var>classNa
54865505
is "<code>xmlns</code>".
54875506
</ul>
54885507

5489-
<p>When supplied, <var>options</var>'s {{ElementCreationOptions/is}} can be used to create a
5490-
<a>customized built-in element</a>.
5508+
<p>When both <var>options</var>'s {{ElementCreationOptions/customElements}} and
5509+
<var>options</var>'s {{ElementCreationOptions/is}} are supplied, a
5510+
"{{NotSupportedError!!exception}}" {{DOMException}} will be thrown.
54915511

54925512
<dt><code><var ignore>documentFragment</var> = <var>document</var> . {{createDocumentFragment()}}</code>
54935513
<dd>Returns a {{DocumentFragment}} <a for=/>node</a>.
@@ -5533,18 +5553,15 @@ method steps are:
55335553
<li><p>If <a>this</a> is an <a>HTML document</a>, then set <var>localName</var> to
55345554
<var>localName</var> in <a>ASCII lowercase</a>.
55355555

5536-
<li><p>Let <var>is</var> be null.
5537-
5538-
<li><p>If <var>options</var> is a <a for=/>dictionary</a> and
5539-
<var>options</var>["{{ElementCreationOptions/is}}"] <a for=map>exists</a>, then set <var>is</var>
5540-
to it.
5556+
<li><p>Let <var>registry</var> and <var>is</var> be the result of
5557+
<a>flattening element creation options</a> given <var>options</var> and <a>this</a>.
55415558

55425559
<li><p>Let <var>namespace</var> be the <a>HTML namespace</a>, if <a>this</a> is an
55435560
<a>HTML document</a> or <a>this</a>'s <a for=Document>content type</a> is
55445561
"<code>application/xhtml+xml</code>"; otherwise null.
55455562

55465563
<li><p>Return the result of <a>creating an element</a> given <a>this</a>, <var>localName</var>,
5547-
<var>namespace</var>, null, <var>is</var>, and true.
5564+
<var>namespace</var>, null, <var>is</var>, true, and <var>registry</var>.
55485565
</ol>
55495566

55505567
<p>The <dfn noexport>internal <code>createElementNS</code> steps</dfn>, given <var>document</var>,
@@ -5554,14 +5571,12 @@ method steps are:
55545571
<li><p>Let <var>namespace</var>, <var>prefix</var>, and <var>localName</var> be the result of
55555572
passing <var>namespace</var> and <var>qualifiedName</var> to <a>validate and extract</a>.
55565573

5557-
<li><p>Let <var>is</var> be null.
5558-
5559-
<li><p>If <var>options</var> is a <a for=/>dictionary</a> and
5560-
<var>options</var>["{{ElementCreationOptions/is}}"] <a for=map>exists</a>, then set <var>is</var>
5561-
to it.
5574+
<li><p>Let <var>registry</var> and <var>is</var> be the result of
5575+
<a>flattening element creation options</a> given <var>options</var> and <a>this</a>.
55625576

55635577
<li><p>Return the result of <a>creating an element</a> given <var>document</var>,
5564-
<var>localName</var>, <var>namespace</var>, <var>prefix</var>, <var>is</var>, and true.
5578+
<var>localName</var>, <var>namespace</var>, <var>prefix</var>, <var>is</var>, true, and
5579+
<var>registry</var>.
55655580
</ol>
55665581

55675582
<p>The
@@ -5570,6 +5585,31 @@ method steps are to return the result of running the
55705585
<a>internal <code>createElementNS</code> steps</a>, given <a>this</a>, <var>namespace</var>,
55715586
<var>qualifiedName</var>, and <var>options</var>.
55725587

5588+
<p>To <dfn>flatten element creation options</dfn>, given a string or {{ElementCreationOptions}}
5589+
dictionary <var>options</var> and a <a for=/>document</a> <var>document</var>:
5590+
5591+
<ol>
5592+
<li><p>Let <var>registry</var> be null.
5593+
5594+
<li><li>Let <var>is</var> be null.
5595+
5596+
<li>
5597+
<p>If <var>options</var> is a dictionary:
5598+
5599+
<ol>
5600+
<li><p>If <var>options</var>["{{ElementCreationOptions/customElements}}"] <a for=map>exists</a>,
5601+
then set <var>registry</var> to it.
5602+
5603+
<li><p>If <var>options</var>["{{ElementCreationOptions/is}}"] <a for=map>exists</a>, then set
5604+
<var>is</var> to it.
5605+
</ol>
5606+
5607+
<li><p>If <var>registry</var> is non-null and <var>is</var> is non-null, then <a>throw</a> a
5608+
"{{NotSupportedError!!exception}}" {{DOMException}}.
5609+
5610+
<li><p>Return <var>registry</var> and <var>is</var>.
5611+
</ol>
5612+
55735613
<p class=note>{{Document/createElement()}} and {{Document/createElementNS()}}'s <var>options</var>
55745614
parameter is allowed to be a string for web compatibility.
55755615

@@ -5635,11 +5675,15 @@ method steps are:
56355675
<hr>
56365676

56375677
<dl class=domintro>
5638-
<dt><var>clone</var> = <var>document</var> . <a method for=Document lt=importNode()>importNode(<var>node</var> [, <var>subtree</var> = false])</a>
5678+
<dt><var>clone</var> = <var>document</var> . <a method for=Document lt=importNode()>importNode(<var>node</var> [, <var>options</var> = false])</a>
56395679
<dd>
5640-
<p>Returns a copy of <var>node</var>. If <var>subtree</var> is true, the copy also includes the
5680+
<p>Returns a copy of <var>node</var>. If <var>options</var> is true or <var>options</var> is a
5681+
dictionary whose {{ImportNodeOptions/selfOnly}} is false, the copy also includes the
56415682
<var>node</var>'s <a for=tree>descendants</a>.
56425683

5684+
<p>If <var>options</var>'s {{ImportNodeOptions/customElements}} can be used to set the
5685+
{{CustomelementRegistry}} of elements that have none.
5686+
56435687
<p>If <var>node</var> is a <a for=/>document</a> or a <a for=/>shadow root</a>, throws a
56445688
"{{NotSupportedError!!exception}}" {{DOMException}}.
56455689

@@ -5655,16 +5699,34 @@ method steps are:
56555699
</dl>
56565700

56575701
<div algorithm>
5658-
<p>The <dfn method for=Document><code>importNode(<var>node</var>, <var>subtree</var>)</code></dfn>
5702+
<p>The <dfn method for=Document><code>importNode(<var>node</var>, <var>options</var>)</code></dfn>
56595703
method steps are:
56605704

56615705
<ol>
56625706
<li><p>If <var>node</var> is a <a for=/>document</a> or <a for=/>shadow root</a>, then <a>throw</a>
56635707
a "{{NotSupportedError!!exception}}" {{DOMException}}.
56645708

5709+
<li><p>Let <var>subtree</var> be false.
5710+
5711+
<li><p>Let <var>registry</var> be false.
5712+
5713+
<li><p>If <var>options</var> is a boolean, then set <var>subtree</var> to <var>options</var>.
5714+
5715+
<li>
5716+
<p>Otherwise:
5717+
5718+
<ol>
5719+
<li><p>Set <var>subtree</var> to the negation of
5720+
<var>options</var>["{{ImportNodeOptions/selfOnly}}"].
5721+
5722+
<li><p>If <var>options</var>["{{ImportNodeOptions/customElements}}"] <a for=map>exists</a>, then
5723+
set <var>registry</var> to it.
5724+
</ol>
5725+
56655726
<li><p>Return the result of <a>cloning a node</a> given <var>node</var> with
5666-
<a for="clone a node"><i>document</i></a> set to <a>this</a> and
5667-
<a for="clone a node"><i>subtree</i></a> set to <var>subtree</var>.
5727+
<a for="clone a node"><i>document</i></a> set to <a>this</a>,
5728+
<a for="clone a node"><i>subtree</i></a> set to <var>subtree</var>, and
5729+
<a for="clone a node"><i>fallbackRegistry</i></a> set to <var>registry</var>.
56685730
</ol>
56695731
</div>
56705732

@@ -6439,12 +6501,12 @@ value of these steps:
64396501
<var>document</var>, string <var>localName</var>, string-or-null <var>namespace</var>, and
64406502
optionally a string-or-null <var>prefix</var> (default null), string-or-null <var>is</var> (default
64416503
null), boolean <var>synchronousCustomElements</var> (default false), and null or a
6442-
{{CustomElementRegistry}} object <var>registry</var>:
6504+
{{CustomElementRegistry}} object <var>registry</var> (default null):
64436505

64446506
<ol>
64456507
<li><p>Let <var>result</var> be null.
64466508

6447-
<li><p>If <var>registry</var> is not given, then set <var>registry</var> to the result of
6509+
<li><p>If <var>registry</var> is null, then set <var>registry</var> to the result of
64486510
<b>looking up a custom element registry</b> given <var>document</var>.
64496511
<!-- XXX xref -->
64506512

0 commit comments

Comments
 (0)