Skip to main content

Bug Tracker

Side navigation

#9977 closed bug (invalid)

Opened August 04, 2011 07:17PM UTC

Closed August 04, 2011 08:24PM UTC

.data() does not return DOM object for method chaining in IE8 and below

Reported by: thegamefreak0134@gmail.com Owned by: thegamefreak0134@gmail.com
Priority: low Milestone: None
Component: data Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

I don't know if this is a bug in jQuery or a bug in the library that I was debugging (I don't know which behavior is correct) but I'm still going to raise it. The following code works in all browsers except IE <= 8. (It functions in IE9, I checked.):

var header = $("<div class='ui-state-default slick-header-column' id='" + uid + m.id + "' />")
.html("<span class='slick-column-name'>" + m.name + "</span>")
.width((m.currentWidth || m.width) - headerColumnWidthDiff)
.attr("title", m.toolTip || m.name || "")
data("fieldId", m.id)
.appendTo($headers);

This code fails in IE8 with an error stating that ....data(...) is null or not an object. In every other browser (Firefox, Chrome, Safari and Opera tested), data() seems to return the dom object and allows .appendTo() to be called. Either way, I was able to fix this by changing the code to the following:

var header = $("<div class='ui-state-default slick-header-column' id='" + uid + m.id + "' />")
.html("<span class='slick-column-name'>" + m.name + "</span>")
.width((m.currentWidth || m.width) - headerColumnWidthDiff)
.attr("title", m.toolTip || m.name || "")
.appendTo($headers);

header.data("fieldId", m.id);

This works as intended in all browsers.

It occurs to me that the behavior of data might be undefined if it is called on an object that has not yet been inserted into the DOM. If this is not actually a bug but a misfeature that the library relied on, then I apologize. Still, I figured I'd let you know.

Attachments (0)
Change History (3)

Changed August 04, 2011 07:52PM UTC by rwaldron comment:1

component: unfileddata
owner: → thegamefreak0134@gmail.com
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.

Changed August 04, 2011 08:19PM UTC by thegamefreak0134@gmail.com comment:2

status: pendingnew

I'm unable to reproduce this as a standalone bug. My apologies, it must be something elsewhere in this mess of code I've inherited.

Changed August 04, 2011 08:24PM UTC by rwaldron comment:3

priority: undecidedlow
resolution: → invalid
status: newclosed