The code for serializing attributes (here:
|
function addSerializedAttribute(buf, qualifiedName, value) { |
|
buf.push(' ', qualifiedName, '="', value.replace(/[<&"]/g,_xmlEncoder), '"') |
|
} |
) does not treat newlines in any special way.
This is a problem, because XML parses literal newlines as spaces. However, it allows newlines in attributes when they are provided as character references. (See: https://www.w3.org/TR/xml/#AVNormalize.)
So:
<element attribute="with
newline"></element>
serializes as
<element attribute="with
newline"></element>
which then gets parsed as
<element attribute="with newline"></element>
which is not equivalent.
The code for serializing attributes (here:
xmldom/lib/dom.js
Lines 1138 to 1140 in 6ce4700
This is a problem, because XML parses literal newlines as spaces. However, it allows newlines in attributes when they are provided as character references. (See: https://www.w3.org/TR/xml/#AVNormalize.)
So:
serializes as
which then gets parsed as
which is not equivalent.