Skip to main content

Bug Tracker

Side navigation

#8235 closed bug (fixed)

Opened February 10, 2011 01:33PM UTC

Closed August 17, 2011 09:22PM UTC

jQuery.data throws a script error in certain circumstances.

Reported by: julian.jelfs@gmail.com Owned by: julian.jelfs@gmail.com
Priority: low Milestone: 1.6.3
Component: data Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

I'm not 100% of the circumstances under which this occurs and I cannot create a simple repro in jsFiddle.

However, there is a bit in jQuery.data as follows:

if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
    return;
}

this is causing a script error when cache[id] is null (a condition that is checked for subsequently).

I am not sure if it is legitimate that we should get to this point and cache[id] is null, but it is certainly happening and only started happening when upgraded to jQuery 1.5.

Seems that the code could be more defensive to prevent the script error (which is what I have done for now in my local copy).

Attachments (0)
Change History (20)

Changed February 10, 2011 05:13PM UTC by jitter comment:1

owner: → julian.jelfs@gmail.com
status: newpending

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

Do you use jQuery UI on the same page? If yes could you try including http://code.jquery.com/jquery-git.js (instead of 1.5) on that page and then check if the error still occurs and then report back if that fixed it for you?

Because there is a known regression in 1.5 which affects jQuery UI and currently it's also not advised/supported to use jQuery UI with jQuery 1.5 .

Probably a duplicate of #8123

Changed February 10, 2011 05:46PM UTC by julian.jelfs@gmail.com comment:2

status: pendingnew

I tried with the suggested version of jquery and I still get the same error.

I am using jquery UI 1.8.6. I will also try upgrading to the 1.8.9.

In the meantime I have just added:

if (id && !cache[ id ] ) {

cache[ id ] = {};

}

before the statement that causes the error and everything seems fine but I don't know if this will have any other unwanted side effects.

Thanks,

Julian.

Changed February 10, 2011 07:06PM UTC by jitter comment:3

component: unfileddata
description: I'm not 100% of the circumstances under which this occurs and I cannot create a simple repro in jsFiddle. \ \ However, there is a bit in jQuery.data as follows: \ \ if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { \ return; \ } \ \ this is causing a script error when cache[id] is null (a condition that is checked for subsequently). \ \ I am not sure if it is legitimate that we should get to this point and cache[id] is null, but it is certainly happening and only started happening when upgraded to jQuery 1.5. \ \ Seems that the code could be more defensive to prevent the script error (which is what I have done for now in my local copy).I'm not 100% of the circumstances under which this occurs and I cannot create a simple repro in jsFiddle. \ \ However, there is a bit in jQuery.data as follows: \ {{{ \ if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { \ return; \ } \ }}} \ this is causing a script error when cache[id] is null (a condition that is checked for subsequently). \ \ I am not sure if it is legitimate that we should get to this point and cache[id] is null, but it is certainly happening and only started happening when upgraded to jQuery 1.5. \ \ Seems that the code could be more defensive to prevent the script error (which is what I have done for now in my local copy).
status: newpending

Without any further information / test case or at least a link to a page where the issue can reproduced we can't take any further steps on this.

So please report back if you can provide any of this so the we can further investigate this issue.

Changed February 18, 2011 11:22AM UTC by anonymous comment:4

I am seeing this exact issue also. It seems to only error on Internet Explorer. I am using IE7. Works successfully on Firefox and Chrome. That might provide a clue to recreating the issue.

Changed March 03, 2011 01:53PM UTC by gmc comment:5

I've got a cut-down version of a page in which I was experiencing this problem - issue only appears in IE, not in FF or Chrome. Also doesn't appear within jsFiddle in IE for some reason - hence link to html fiel below.

There is a link to the recreated issue below. The qunit test passes when the page is changed to point at a patched version of jquery 1.5.1 in which the line:

if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {

is changed to:

if ( (!id || (pvt && id && cache[ id ] && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {

Page recreating issue: https://docs.google.com/leaf?id=0BxFi8HJljH7LN2YzNzg1ZGQtMmVhMC00ZDg4LWE5NDEtMDI0MDQ2MDlkNjkz&hl=en&authkey=CN-Ik8kF

Changed March 19, 2011 07:49AM UTC by trac-o-bot comment:6

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed May 04, 2011 01:35PM UTC by niebieskiii@poczta.fm comment:7

I have the same issue that exists only in IE7 and only with jquery version grater than 1.4.4

Test case:

http://jsfiddle.net/ZP2T6/

  • run it under ie7
  • add 2 items by clicking 'add new'
  • remove 2 items by clicking 'remove'

you get error on page in jquery line mentioned earlier in this topic

''''''''

Changed June 24, 2011 09:07PM UTC by dalugadm comment:8

I too am seeing this issue. It appears to happen in IE7 and IE8 (I have not tried IE9). FF does not appear to have any problems. I am using 1.6.1.

The example provided by niebieskiii seems to reproduce the problem. Is there any plans to investigate this issue further? I have modified my local copy to make it work but would prefer a JQuery accepted solution so that it has been properly regression tested.

Changed June 24, 2011 10:23PM UTC by rwaldron comment:9

This: http://jsfiddle.net/ZP2T6/ is not a reduced test case of which we can base an attempt to fix the problem on...

Please reduce this further without jQuery UI present

Changed June 27, 2011 02:07PM UTC by dalugadm comment:10

In my limited testing, once I remove JQuery UI, the problem appears to disappear. So, at first glance, it appears to be some type of interaction between JQuery and JQuery UI.

Since I am new here, what would be the next step? I appreciate your time in helping with this!

Changed June 27, 2011 03:18PM UTC by rwaldron comment:11

That's very helpful, thank you. You'll want to refile this ticket here: http://bugs.jqueryui.com/

Changed June 27, 2011 03:19PM UTC by rwaldron comment:12

priority: undecidedlow

Changed June 27, 2011 08:53PM UTC by dalugadm comment:13

Thank you rwaldron!

For anyone interested, I have refiled the ticket here: http://bugs.jqueryui.com/ticket/7510

Changed August 09, 2011 03:38PM UTC by scottgonzalez comment:14

resolution: invalid
status: closedreopened

https://github.com/jquery/jquery/blob/b22c9046529852c7ce56/src/data.js#L54

cache[ id ][ internalKey ] is checked without ensuring that cache[ id ] exists.

I'm not really sure how we end up in that situation, but this should be fixed in core.

Changed August 09, 2011 04:27PM UTC by timmywil comment:15

status: reopenedopen

Changed August 09, 2011 04:27PM UTC by timmywil comment:16

milestone: 1.next1.6.3

Changed August 16, 2011 01:29PM UTC by rwaldron comment:17

#10061 is a duplicate of this ticket.

Changed August 17, 2011 09:02PM UTC by rwaldron comment:18

#10080 is a duplicate of this ticket.

Changed August 17, 2011 09:08PM UTC by rwaldron comment:19

#10080 is a duplicate in that it is the same behaviour, different location in the code

Changed August 17, 2011 09:22PM UTC by Rick Waldron comment:20

resolution: → fixed
status: openclosed

Landing pull request 459. Do not allow assumed cache[id] in jQuery.data. Fixes #8235.

More Details:

Changeset: 130a29e78666def3b477056978406ea2fbcdad2b