Closed Bug 277774 Opened 21 years ago Closed 21 years ago

e4x: setNamespace() changes namespace() but doesn't show up with namespaceDeclarations()

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 290056

People

(Reporter: martin.honnen, Unassigned)

Details

When I create an XML element in no namespace and then call setNamespace on it the method namespace() returns that namespace but the method namespaceDeclarations() returns an empty array. I think the result of namespaceDeclarations() should reflect the added namespace so I file this bug. Rhino shows the added namespace with namespaceDeclarations(). Test case: function testNamespaces (xml) { var result = ''; result += 'Checking ' + xml.toXMLString() + ' : \r\n'; result += '.namespace(): ' + xml.namespace() + '\r\n'; result += '.namespaceDeclarations().length: ' + xml.namespaceDeclarations().length + '\r\n'; return result; } var xhtml1NS = new Namespace('http://www.w3.org/1999/xhtml'); var xhtml = <html />; xhtml.setNamespace(xhtml1NS); var result = testNamespaces(xhtml); if (typeof alert == 'function') { alert(result); } else if (typeof print == 'function') { print(result); } Result with Spidermonkey: Checking <html xmlns="http://www.w3.org/1999/xhtml"/> : .namespace(): http://www.w3.org/1999/xhtml .namespaceDeclarations().length: 0 Result with Rhino: Checking <xht:html xmlns:xht="http://www.w3.org/1999/xhtml"/> : .namespace(): http://www.w3.org/1999/xhtml .namespaceDeclarations().length: 1
The ECMA-357 spec clearly does *not* [[AddInScopeNamespace]] or any similar thing for XML.prototype.setNamespace (13.4.4.36). Is this really a bug in SpiderMonkey, or in ECMA-357, or in Rhino? If the current spec is right, then it's a bug in Rhino. If the spec is wrong, we need an erratum (collected in bug 246441 via attachment), and we need a spec-fix. In particular, should the namespace have a prefix auto-generated for it? /be
I'm convinced this is a Rhino bug. SpiderMonkey follows the spec, which makes more sense if you consider that namespace() describes something that may not have been declared, while namespaceDeclarations() returns what was declared, and what was added by addNamespace. Someone please file a Rhino bug. /be
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Bug 278112 is Rhino counterpart of this
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
*** This bug has been marked as a duplicate of 290056 ***
Status: REOPENED → RESOLVED
Closed: 21 years ago21 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.