Opened 13 years ago
Closed 12 years ago
#6968 closed bug (fixed)
"handle" won't work as a key for .data() method
Reported by: | itachi | Owned by: | snover |
---|---|---|---|
Priority: | blocker | Milestone: | 1.5 |
Component: | data | Version: | 1.4.3 |
Keywords: | needstest patch | Cc: | |
Blocked by: | Blocking: | #7840 |
Description
--- to reproduce, evaluate:
/* any jQuery el */
var $el = $(document)
/* set "handle" to anything but a function */
$el.data("handle", {}))
/* this fails, see line 1850 where jQuery.trigger() function assumes that jQuery.data( elem, "handle" ) is a function */
$el.data("handle")
--- expected: "handle" keyword work or is marked invalid in docs
Change History (14)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
need: | Review → Patch |
---|
Also used internally:
__className__ handle events _change_data lastToggle events olddisplay
comment:3 Changed 13 years ago by
Milestone: | 1.4.3 → 1.next |
---|---|
Priority: | → blocker |
Status: | new → open |
Version: | 1.4.2 → 1.4.3 |
We need to stop polluting the data objects with internal data. 1.4.3 also adds __events__
as a polluting key.
comment:5 Changed 13 years ago by
Keywords: | needstests patch added |
---|
comment:6 Changed 13 years ago by
Keywords: | needstest added; needstests removed |
---|
comment:7 Changed 13 years ago by
what about using jQuery.expando + "_events",...
this would remove all collision possibilities.
however it would also pollute the display in FireQuery (Firebug addon)
maybe reserve "jQuery." as prefix a user may not use
comment:8 follow-up: 12 Changed 12 years ago by
It seems sane to have $ as prefix for all jquery native stuff, or even $, like: "" as hidden library stuff and "$" pointing that it is jquery library stuff.
comment:10 Changed 12 years ago by
Blocking: | 7840 added |
---|
comment:11 Changed 12 years ago by
Owner: | set to snover |
---|---|
Status: | open → assigned |
comment:12 Changed 12 years ago by
Replying to iliakan:
It seems sane to have $ as prefix for all jquery native stuff, or even $, like: "" as hidden library stuff and "$" pointing that it is jquery library stuff.
I kinda like that idea... .data('$')['events']
or .data('$events')
either seems less polluting for the internals. I wonder how many people are using .data('events')
or other internal keys for their own code/purposes though. Either suggestion would be easy enough to compat mode, making the .data strip the $ off the argument.
comment:14 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Merge in data_nocollide branch. Fixes #6968, improves unit testing framework checks for leaky stuff.
Changeset: e78d3a7e2d47e9796f87c18b76f8178b0bee42c5
Good point, perhaps it would be a good idea for jQuery to use a leading $ for its data names to avoid conflicts.