Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10757 closed bug (invalid)

attr(): on XML documents returns "undefined"

Reported by: Thomas Scheffler Owned by: Thomas Scheffler
Priority: low Milestone: None
Component: attributes Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


After updating from 1.6.2 to 1.7 I noticed a bug. I load a XML document via AJAX request and process it via some jQuery methods, but attr() does not return a value anymore.



returns "MASTER"


returns undefined

in 1.6.2 the jQuery code gave the same result as the DOM only code: "MASTER"

groups[i] is a XML element node.

Change History (4)

comment:1 Changed 11 years ago by Timmy Willison

Component: unfiledattributes
Owner: set to Thomas Scheffler
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 11 years ago by Thomas Scheffler

Status: pendingnew

Here is a minimal testcase. jQuery Edge is still broken, while 1.6.4 works fine


There is a problem with document.importNode(). If I skip that it works fine on Mozilla, but for cross browser support this call is needed.

comment:3 Changed 11 years ago by dmethvin

I'll let timmywil weigh in on this, but I'll observe that by calling document.importNode on the element you've changed it from an XML node to an HTML one.

comment:4 Changed 11 years ago by Timmy Willison

Resolution: invalid
Status: newclosed

Dave hit it on the nose. It works fine if importNode is not used to convert it: http://jsfiddle.net/timmywil/TtPBn/1/

The problem is that it is actually invalid to have uppercase attributes on html nodes. When attached to an html doc using importNode, the xml node becomes an invalid html node and the attribute names do not get lowercased as one may expect. As of 1.7, we always lowercase the name (which mostly helps with attributes like contentEditable where people don't always realize that the attribute should be retrieved with "contenteditable").

For reference, see the note in the spec

I recommend not using importNode as that's not what it is meant for anyway. https://developer.mozilla.org/en/DOM/document.importNode

Note: See TracTickets for help on using tickets.