Bug Tracker

Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#6890 closed enhancement (patchwelcome)

jQuery.data() does not work on XML in IE

Reported by: stephenr85 Owned by:
Priority: undecided Milestone:
Component: data Version: 1.4.2
Keywords: IE, XML, expando Cc:
Blocked by: Blocking:


It looks like the ActiveX object that IE uses for XML does not allow the jQuery expando attribute to be attached for data() references.

Steps to produce:

  1. Load XML doc via $.ajax.
  2. In success callback, $(data).find("anyNode").data("myDataKey", "my value");

Change History (7)

comment:1 Changed 7 years ago by stephenr85

Forgot to mention, a possible workaround would be to add the expando value as an attribute of the node, rather than a property of the object. It works, but could cause some obvious issues where the XML is sent back to the server for saving or validation. There could be a jQuery.cleanXMLData() utility method added to remove the attributes, but...bleh.

The other idea would be to store an array of {target:obj, data:obj} object and do a sort-of indexOf looking for target, but that has its efficiency issues.

If there's another workaround for adding properties to IE XML Node objects, I'd like to hear 'em.

comment:2 Changed 7 years ago by dmethvin

What if we documented that .data() is not supported cross-browser on XML documents? The workarounds here seem complex, and there don't seem to have been a lot of people inconvenienced by the issue.

comment:3 Changed 7 years ago by addyosmani

Priority: undecided

@dmethvin Given that the original ticket submitter hasn't responded to this ticket in 2 months, what are your thoughts on updating the documentation to reflect your original suggestion?.

comment:4 Changed 7 years ago by addyosmani

Status: newopen
Type: bugenhancement

We've decided to document this behavior in the API Documentation and move this ticket to enhancements. If you have any further comments please feel free to add them.

comment:5 Changed 6 years ago by snover

Milestone: 1.4.3

Resetting milestone to future.

comment:6 Changed 6 years ago by ddstreet

Can you also modify the documentation for the bind() function, as I used custom events on XML document elements and didn't realize that would not work on IE either. The bind() function documentation currently states you can't bind to "object, embed, or applet elements" but does not mention XML elements.

Also, I would love to see this worked around at some point, as setting data() and using events with XML elements is very useful to me and works (as far as I can tell) everywhere except IE...

comment:7 Changed 6 years ago by john

Resolution: patchwelcome
Status: openclosed

Yeah, I don't think that this is something that we can reasonably resolve. Patches welcome.

Note: See TracTickets for help on using tickets.