Bug Tracker

Modify

Ticket #10757 (closed bug: invalid)

Opened 20 months ago

Last modified 15 months ago

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:
Blocking: Blocked by:

Description

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.

While

groups[i].getAttribute("USE")

returns "MASTER"

jQuery(groups[i]).attr("USE")

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

comment:1 Changed 20 months ago by timmywil

  • Owner set to Thomas Scheffler
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to attributes

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 19 months ago by Thomas Scheffler

  • Status changed from pending to new

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

 http://jsfiddle.net/TtPBn/

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 19 months 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 19 months ago by timmywil

  • Status changed from new to closed
  • Resolution set to invalid

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.