Closed
Bug 251573
Opened 21 years ago
Closed 20 years ago
Missing namespace declarations when adding NS'ed elements/attributes to a document programmatically
Categories
(Core :: DOM: Serializers, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: zigsterz, Assigned: peterv)
References
()
Details
(Keywords: fixed-aviary1.0, fixed1.7.5)
Attachments
(1 file)
1.92 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
mkaply
:
approval1.7.5+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707
The problem manifested itself in two forms:
(a) Doing a attr=createAttributeNS, then element.setAttributeNode(attr) should
trigger the creation of a namespace declaration for attr.namespaceURI on
element. It doesn't.
(b) When doing appendChild(elem) where elem=createElementNS(...), a namespace
declaration isn't emitted if a previous element with the same namespace
prefix/URI was appended to the same parent without children. Demonstration code
snippet:
var doc = document.implementation.createDocument("", "",
null);
doc.appendChild(doc.createElement("R"));
lE1 = doc.createElementNS("http://one.org/", "a:one");
doc.documentElement.appendChild(lE1);
lE1.appendChild(doc.createTextNode("")); // <------ ***
lE2 = doc.createElementNS("http://one.org/", "a:two");
doc.documentElement.appendChild(lE2);
alert("DOC: " + ( new XMLSerializer ).serializeToString(
doc ));
When removing the line marked with asterisks, lE2 won't include a namespace
declaration -- only lE1.
Probably in the absence of a closing tag someone forgets to change the
namespace resolution context.
Reproducible: Always
Steps to Reproduce:
See details.
Actual Results:
See details.
Comment 1•21 years ago
|
||
Please attach a testcase showing the problem (and if there are two distinct
problems, please file two separate bugs on them).
Assignee: general → dom-to-text
Component: DOM → DOM to Text Conversion
QA Contact: ian
And please point out what part of the spec we're not following.
Assignee | ||
Comment 3•21 years ago
|
||
Problem a isn't a bug: you need to use setAttributeNodeNS.
To fix problem b we probably need to add a call to PopNameSpaceDeclsFor at the
end of nsXMLContentSerializer::AppendElementStart for the case of an element
without children
(http://lxr.mozilla.org/seamonkey/source/content/base/src/nsXMLContentSerializer.cpp#592).
Assignee | ||
Comment 4•21 years ago
|
||
Actually, it probably should be in nsXMLContentSerializer::AppendElementEnd
(http://lxr.mozilla.org/seamonkey/source/content/base/src/nsXMLContentSerializer.cpp#611).
Assignee | ||
Comment 5•21 years ago
|
||
Assignee: dom-to-text → peterv
Status: NEW → ASSIGNED
Assignee | ||
Updated•21 years ago
|
Attachment #153872 -
Flags: superreview?(bzbarsky)
Attachment #153872 -
Flags: review?(bzbarsky)
Comment 6•21 years ago
|
||
Comment on attachment 153872 [details] [diff] [review]
v1
r+sr=bzbarsky
Attachment #153872 -
Flags: superreview?(bzbarsky)
Attachment #153872 -
Flags: superreview+
Attachment #153872 -
Flags: review?(bzbarsky)
Attachment #153872 -
Flags: review+
Assignee | ||
Comment 7•21 years ago
|
||
Comment on attachment 153872 [details] [diff] [review]
v1
Trivial fix so that the XML serializer doesn't create invalid XML documents.
Low risk.
Attachment #153872 -
Flags: approval1.7.2?
Comment 8•21 years ago
|
||
Comment on attachment 153872 [details] [diff] [review]
v1
a=mkaply
Attachment #153872 -
Flags: approval1.7.2? → approval1.7.2+
Assignee | ||
Comment 9•20 years ago
|
||
Checked in to the (closed) 1.7 branch. Didn't notice it was closed, so feel free
to bug me it it needs to be backed out.
Updated•20 years ago
|
Keywords: fixed1.7 → fixed1.7.3
Keywords: fixed-aviary1.0
You need to log in
before you can comment on or make changes to this bug.
Description
•