From 97e7bb3182f28555d2b5deff01a75d1a87cfd346 Mon Sep 17 00:00:00 2001 From: Stef Busking Date: Thu, 13 Jul 2017 16:18:14 +0200 Subject: [PATCH] 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 #29 --- index.html | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index d86da6a..24ae85e 100644 --- a/index.html +++ b/index.html @@ -1359,11 +1359,19 @@

Extensibility

"xmlns". -
  • Otherwise, the attribute namespace in not the XMLNS namespace. Run - these steps: +
  • Otherwise, the attribute namespace is not the XMLNS namespace. If + candidate prefix is null, run these steps:
      -
    1. Let candidate prefix be the result of generating a prefix providing - map, attribute namespace, and prefix index as input. +
    2. Let new prefix be attr's prefix attribute if it is + not null and the local prefixes map does not contain a key matching + attr's prefix, or the result of generating a prefix providing + map, attribute namespace, and prefix index as input otherwise. + +
    3. Add new prefix to map given namespace attribute namespace. + +
    4. Add the value of new prefix as a new key to the local prefixes map, with + the attribute namespace as the key's value replacing the value of null with + the empty string if applicable.
    5. Append the following to result, in the order listed:
        @@ -1371,7 +1379,7 @@

        Extensibility

      1. The string "xmlns:"; -
      2. The value of candidate prefix; +
      3. The value of new prefix;
      4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK);