Side navigation
#907 closed bug (fixed)
Opened February 01, 2007 08:22PM UTC
Closed February 05, 2007 08:20PM UTC
Last modified June 20, 2007 01:53AM UTC
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.
Attachments (0)
Change History (7)
Changed February 01, 2007 08:24PM UTC by comment:1
Changed February 02, 2007 01:37AM UTC by comment:2
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
Changed February 02, 2007 07:50AM UTC by comment:3
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
Changed February 02, 2007 07:10PM UTC by comment:5
component: | ajax → core |
---|
Changed February 02, 2007 09:34PM UTC by comment:6
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.
Changed February 05, 2007 08:20PM UTC by comment:7
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?