Opened 13 years ago
Closed 12 years ago
#6304 closed bug (fixed)
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>
Change History (1)
comment:1 Changed 12 years ago by
Priority: | → undecided |
---|---|
Resolution: | → fixed |
Status: | new → closed |
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