Bug Tracker

Ticket #6890 (closed enhancement: patchwelcome)

Opened 4 years ago

Last modified 3 years ago

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

Description

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

comment:1 Changed 4 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 4 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 4 years ago by addyosmani

  • Priority set to 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 4 years ago by addyosmani

  • Status changed from new to open
  • Type changed from bug to enhancement

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 4 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:6 Changed 4 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 4 years ago by john

  • Status changed from open to closed
  • Resolution set to patchwelcome

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

Note: See TracTickets for help on using tickets.