$(element).data("events") API removed in jQuery v1.8 #118

Closed
redclov3r opened this Issue Sep 25, 2012 · 3 comments

3 participants

@redclov3r

In line 403 of sequence.jquery.js there is

if(self.sequence.data("events").mousemove === undefined){
    self.sequence.mousemove(function(e){
        hoverDetect(e);
    });
}

The $(element).data("events") API has been removed in version >=1.8 (Changelog). Every mouseleaveevent on a sequence object throws an error like this:

Uncaught TypeError: Cannot read property 'mousemove' of undefined

I haven't found a proper replacement yet, but I'm asking myself why the if statement there is necessary at all and if it may be omitted completely.

@tristanm

To expand on what @redclov3r said, $(element).data("events") can be replaced with $._data(element, "events") in jQuery 1.8 as per the jQuery Blog:

$(element).data(“events”): In version 1.6, jQuery separated its internal data from the user’s data to prevent name collisions. However, some people were using the internal undocumented “events” data structure so we made it possible to still retrieve that via .data(). This is now removed in 1.8, but you can still get to the events data for debugging purposes via $._data(element, "events"). Note that this is not a supported public interface; the actual data structures may change incompatibly from version to version.

Patch for backwards and forwards compatibility:

if((self.sequence.data("events") || $._data(self.sequence[0], "events")).mousemove === undefined){
    self.sequence.mousemove(function(e){
        hoverDetect(e);
    });
}
@IanLunn
Owner

Thanks for pointing this out. I'll fix this in the next version (and probably just remove that code entirely).

@IanLunn
Owner

v0.7.4 is now compatible with jQuery 1.8.2. Thanks.

@IanLunn IanLunn closed this Oct 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment