Bug 41519
| Summary: | Unable to create xmlns attribute | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Laurens Holst <laurens.nospam> |
| Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | Normal | CC: | annevk, ap, cdumez, rwlbuis |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | PC | ||
| OS: | OS X 10.5 | ||
Laurens Holst
This incorrectly fails with a NAMESPACE_ERR:
document.createAttribute('http://www.w3.org/2000/xmlns/', 'xmlns')
The problem is here: http://trac.webkit.org/browser/trunk/WebCore/dom/Document.cpp#L850
This code only checks for prefixes, whereas the spec says that this should also check for qualified name:
- if ((qName.prefix() == xmlnsAtom && qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI) || (qName.prefix() != xmlnsAtom && qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI))
- return true;
+ if (((qName.prefix() == xmlnsAtom || qName.toString() == xmlnsAtom) && qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI) || ((qName.prefix() != xmlnsAtom || qName.toString() == xmlnsAtom) && qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI))
+ return true;
See:
http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-DocCrElNS
http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-DocCrAttrNS
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Rob Buis
(In reply to comment #0)
> This incorrectly fails with a NAMESPACE_ERR:
>
> document.createAttribute('http://www.w3.org/2000/xmlns/', 'xmlns')
I assume you mean createElementNS here, since you reference it below.
> The problem is here: http://trac.webkit.org/browser/trunk/WebCore/dom/Document.cpp#L850
>
> This code only checks for prefixes, whereas the spec says that this should also check for qualified name:
>
> - if ((qName.prefix() == xmlnsAtom && qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI) || (qName.prefix() != xmlnsAtom && qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI))
> - return true;
> + if (((qName.prefix() == xmlnsAtom || qName.toString() == xmlnsAtom) && qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI) || ((qName.prefix() != xmlnsAtom || qName.toString() == xmlnsAtom) && qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI))
> + return true;
>
> See:
> http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-DocCrElNS
> http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-DocCrAttrNS
When I use this with trunk:
document.createAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns')
it will create an attribute, which would mean this bug can be closed. Can you verify with a recent build?
Lucas Forschler
Mass moving XML DOM bugs to the "DOM" Component.
Anne van Kesteren
As per comment 1.