Closed Bug 505178 Opened 16 years ago Closed 7 years ago

Default namespace for HTML elements should be http://www.w3.org/1999/xhtml

Categories

(Core :: DOM: Core & HTML, defect, P3)

x86
Windows XP
defect

Tracking

()

RESOLVED DUPLICATE of bug 1061578
mozilla1.9.2b1

People

(Reporter: nanto, Assigned: hsivonen)

References

(Depends on 1 open bug)

Details

Attachments

(2 files)

From bug 312019 comment 17 > Since bug 468708 was fixed, the namespace of HTML elements is now > "http://www.w3.org/1999/xhtml". But HTMLElement.lookupNamespaceURI(null) still > returns null. This behavior differs from WebKit, which correctly returns > "http://www.w3.org/1999/xhtml", and can break some scripts that assume > lookupNamespace(null) returns the default namespace, such as AutoPagerize [1]. > > [1] http://userscripts.org/scripts/show/8551 See the attachment to reproduce this bug. Expected results: http://www.w3.org/1999/xhtml true Actual results: null false
Henri, this is a spec compliance bug, and a bug that affects compatibility with other browsers as well? If so, I think we should fix this for 1.9.2. Seems relatively straight forward to fix this. Or do we think this is likely to break existing websites?
Assignee: nobody → hsivonen
Flags: blocking1.9.2+
Priority: -- → P2
It certainly looks like a spec compliance bug. For elements, the DOM3 spec basically calls for (see <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html#lookupNamespaceURIAlgo>): if ( Element's namespace != null and Element's prefix == prefix ) { // Note: prefix could be "null" in this case we are looking for default // namespace return (Element's namespace); } if ( Element has attributes) { // do some stuff (that we don't do quite right either, for attributes with // empty value } // Recurse to ancestors nsContentUtils::LookupNamespaceURI doesn't do that first part (and doesn't do empty attrs quite per spec either, as I said).
Note that we have a bug on lookupNameSpaceURI not following the spec (bug 312019), but I asked to file a separate bug on |HTMLElement.lookupNamespaceURI(null)|. If we want to fix all the bugs in that algorithm we should probably dupe this again, but for now the HTMLElement bug seemed more important than some of the other stuff.
I've never liked the lookupNamespaceURI algorithm in the spec as it makes it hard to impossible to control namespace mappings using the DOM. nanto_vi: Why exactly does AutoPagerize need for lookupNamespaceURI(null) to return the XHTML namespace?
(In reply to comment #4) > nanto_vi: Why exactly does AutoPagerize need for lookupNamespaceURI(null) to > return the XHTML namespace? My comment 0 is incorrect. What breaks AutoPagerize is bug 312019. In addition, AutoPagerize will be updated to avoid that bug. AutoPagerize uses lookupNamespaceURI(null) to get the default namespace surely in XHTML/XML documents which contain multiple vocabularies (e.g., [1]). In such documents, element.lookupNamespaceURI(null) may differ from element.namespaceURI and AutoPagerize wants the former to treat non-prefixed XPath node-tests as if they belong to the default namespace. That is, AutoPagerize uses lookupNamespaceURI(null) for XHTML/XML documents, not for HTML documents. [1] http://www.kanzaki.com/docs/sw/meta-in-xh.html (written in Japanese) However, I still hope this bug fixed in 1.9.2 so that we can write codes for HTML and for XHTML in the same manner, and for Gecko and for WebKit as well.
But why do you want to get the default namespace? Even if multiple vocabularies are used, wouldn't you still just want the elements with a certain name+namespace?
What I thought is using prefix and namespace URI pairs described in a page. http://www.kanzaki.com/docs/sw/meta-in-xh.html contains the following pairs: (null) -> http://www.w3.org/1999/xhtml foaf -> http://xmlns.com/foaf/0.1/ dct -> http://purl.org/dc/terms/ rdf -> http://www.w3.org/1999/02/22-rdf-syntax-ns# rdfs -> http://www.w3.org/2000/01/rdf-schema# dc -> http://purl.org/dc/elements/1.1/ cc -> http://web.resource.org/cc/ It looked better to use these combination rather than to create a large database for all existing namespaces. But now I think it may be the worse way. This approach can't be applied to the following markup: <p>See the image: <svg xmlns="http://www.w3.org/2000/svg">...</svg> </p> and HTML5 HTML syntax (or at least Mozilla's HTML5 parser) allows only this type of markup.
This still doesn't describe *why* you need any of the mappings in the page. Can you describe in detail what it is that your page needs to do? I.e. are you trying to find all the links in a page? Or all the elements? Or count all the namespaces? Put another way, say that we fixed this bug. What would your page do differently?
This is both a spec compliance and a WebKit parity bug. I agree that we should target this to 1.9.2.
Status: NEW → ASSIGNED
I'm unconvinced. The spec really is rather useless here. It makes it basically impossible to modify which prefixes are in scope where using the DOM.
Attached patch FixSplinter Review
(In reply to comment #10) > I'm unconvinced. The spec really is rather useless here. It makes it basically > impossible to modify which prefixes are in scope where using the DOM. I agree the spec is questionable due to the reason you point out. Should we try to get the spec changed here? I tend to fight Namespace-induced badness, but I don't care enough about this case to pursue a spec change. Another perspective is that using the DOM to change which prefixes are in scope is in itself a bad exercise, because it makes sense mostly for synthetic qnames-in-content stuff, and qnames-in-content is an anti-pattern anyway. Anyway, here's a patch that makes Gecko behave better per spec. (As far as I can tell, the spec doesn't license the hard-wiring of 'xml' and 'xmlns', but that looks like a spec bug to me, so I didn't make those behave per spec.)
Attachment #394505 - Flags: review?(jonas)
I think we should try to get the spec changed yes. The spec currently only makes sense in scenarios where a parser drops xmlns attributes, but no browsers do that anyway.
For the purposes of the lookup algorithm, trees created by the HTML5 parser are trees without the xmlns attributes, which is why compying with the spec as written fixes this bug.
XML-mode demo: http://hsivonen.iki.fi/test/moz/lookupNamespaceURI.xhtml Findings: * In Gecko, both null and "" mean no prefix. * In WebKit, null means no prefix, but "" isn't supported. * In Opera, "" means no prefix, but null isn't supported. * Opera and WebKit, for the value they do recognize, implement the algorithm per spec to the point of not hard-wiring "xml" and "xmlns" See also http://krijnhoetmer.nl/irc-logs/whatwg/20090817#l-706 and onwards.
sicking, what are the next steps here considering comment 13 and comment 14? Should we still go for a spec change (which would essentially involve convincing WebKit devs to change WebKit lookup algorithm to disagree with DOM Level 3)? If so, what should the spec say? In particular, are you suggesting changing the identity elt.isDefaultNamespace(elt.lookupNamespaceURI(null)) == true?
I think this is the sort of change that should get as much up front testing as possible, let's get this in for beta.
Priority: P2 → P1
Target Milestone: --- → mozilla1.9.2b1
I still think this bug is a WONTFIX. The way the spec is written only makes sense if you want things still to "work" even if the parser dropps xmlns attributes (something I believe the DOM L&S spec allowed). However no relevant parser in this context actually does that. Nor would prefix mapping actually work reliably if it did. So yes, I think we should bring this up in WebApps and see if we can get webkit to change. Also, I really don't think there is much risk that this will cause any significant compatibility problems. If we can't get people to agree with what we think is the correct solution I don't see it as a problem to fix this in next release even.
Ok, not blocking 1.9.2 on this per the above comments.
Flags: blocking1.9.2+ → blocking1.9.2-
Shall we WONTFIX this bug and bug 312019?
Status: ASSIGNED → NEW
Attachment #394505 - Flags: review?(jonas)
I think so. Though definitely worth raising this with whoever ends up developing the "Web Core" spec.
That DOM specification is being developed now, it would be great if you could give feedback on our algorithms: http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
Maybe we should duplicate this against bug 1061578 too.
Priority: P1 → P3
Depends on: 1061578
We're still different from Chrome on this point, and I think we should take a fix if someone writes one. (I.e. I disagree with comment 17.)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: