Skip to main content

Bug Tracker

Side navigation

#6304 closed bug (fixed)

Opened March 18, 2010 04:19AM UTC

Closed September 24, 2010 08:31PM UTC

calling $(...).data() changes behaviour of $(...).data('nosuchkey')

Reported by: tgdavies2 Owned by:
Priority: undecided Milestone: 1.4.3
Component: data Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

If you call ...data('foo') you get a result of null, but if you then call ...data() followed by ...data('foo') the result is undefined:

<html>

<head>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>

<script type="text/javascript">

$(document).ready(function() {

$("#firstvalue").html(typeof $("#foo").data('bar'));

var ignored = $("#foo").data();

$("#secondvalue").html(typeof $("#foo").data('bar'));

});

</script>

</head>

<body>

<div id="foo">Div named foo</div>

<div>First value of $("#foo").data('bar'):<span id="firstvalue"/></div>

<div>Second value of $("#foo").data('bar'):<span id="secondvalue"/></div>

</body>

</html>

Attachments (0)
Change History (1)

Changed September 24, 2010 08:31PM UTC by john comment:1

priority: → undecided
resolution: → fixed
status: newclosed

I wasn't able to replicate this (namely the result of null) so I think this is fixed on our end. I added some extra tests:

http://github.com/jquery/jquery/commit/515efbdc7119aa79de710144effe18413d4cb14a