#907 closed bug (fixed)
Don't apply fixes in attr for XML documents
Reported by: | joern | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | core | Version: | |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The following code can be used to detect if an element is in a normal document:
if ( element.ownerDocument.body ) { // This is an HTML document }
With that, fixes like for - forClass and class - className can be avoided in XML documents.
Change History (7)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
If you try this code on this page (using firebug or any JavaScript console)
jQuery("p")[0].ownerDocument.body
you'll see that it returns the <body> element, so I don't think that quite works
comment:3 Changed 16 years ago by
D'oh! Forget my last comment, I misread Joern's example!
It seems to work fine in every browser except IE 5.5 (couldn't test Safari), where HTML elements don't seem to have an ownerDocument property (XML elements do, though).
Test page: http://aheimlich.freepgs.com/tests/jquery/htmlelem-or-xmlelem/
I guess you could do
!elem.ownerDocument || elem.ownerDocument.body
but I don't know how Safari would react to that
comment:5 Changed 16 years ago by
Component: | ajax → core |
---|
comment:6 Changed 16 years ago by
I got the chance to test my IE 5.5 workaround on Safari 2.0.3 and it didn't seem to cause any problems. If someone can test this on Safari 1, then I think we have a solution.
comment:7 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in revision 1286. Unfortuanetely, the href bug is another story. getAttribute("href", 2) simply doesn't work, it returns the absolute URL every time.
I hope we get the refactoring for attr/css at some point, I had to check for element.tagName once more.
Like this?