Skip to content

Commit 97e7bb3

Browse files
committed
Only generate an attribute prefix if required
If implemented as specified, the prefix set for an attribute in the DOM would never be preserved during serialization. This change only generates the new prefix if the prefix is either missing (which is not allowed for namespaced attributes), or if it conflicts with another local namespace definition of the prefix for a different namespace. Fixes w3c#29
1 parent d620191 commit 97e7bb3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

index.html

+13-5
Original file line numberDiff line numberDiff line change
@@ -1359,19 +1359,27 @@ <h2>Extensibility</h2>
13591359
"<code>xmlns</code>".
13601360
</ol>
13611361

1362-
<li>Otherwise, the <var>attribute namespace</var> in not the <a>XMLNS namespace</a>. Run
1363-
these steps:
1362+
<li>Otherwise, the <var>attribute namespace</var> is not the <a>XMLNS namespace</a>. If
1363+
<var>candidate prefix</var> is null, run these steps:
13641364
<ol>
1365-
<li>Let <var>candidate prefix</var> be the result of <a>generating a prefix</a> providing
1366-
<var>map</var>, <var>attribute namespace</var>, and <var>prefix index</var> as input.
1365+
<li>Let <var>new prefix</var> be <var>attr</var>'s <code><a>prefix</a></code> attribute if it is
1366+
not <code>null</code> and the <var>local prefixes map</var> does not contain a key matching
1367+
<var>attr</var>'s <code><a>prefix</a></code>, or the result of <a>generating a prefix</a> providing
1368+
<var>map</var>, <var>attribute namespace</var>, and <var>prefix index</var> as input otherwise.
1369+
1370+
<li><a>Add</a> <var>new prefix</var> to <var>map</var> given namespace <var>attribute namespace</var>.
1371+
1372+
<li>Add the value of <var>new prefix</var> as a new key to the <var>local prefixes map</var>, with
1373+
the <var>attribute namespace</var> as the key's value replacing the value of <code>null</code> with
1374+
the empty string if applicable.
13671375

13681376
<li>Append the following to <var>result</var>, in the order listed:
13691377
<ol>
13701378
<li>"<code> </code>" (U+0020 SPACE);
13711379

13721380
<li>The string "<code>xmlns:</code>";
13731381

1374-
<li>The value of <var>candidate prefix</var>;
1382+
<li>The value of <var>new prefix</var>;
13751383

13761384
<li>"<code>="</code>" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);
13771385

0 commit comments

Comments
 (0)