Side navigation
#6968 closed bug (fixed)
Opened August 30, 2010 11:09AM UTC
Closed January 17, 2011 09:33PM UTC
"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: |
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
Attachments (0)
Change History (14)
Changed August 31, 2010 12:00AM UTC by comment:1
Changed September 03, 2010 01:46PM UTC by comment:2
| need: | Review → Patch |
|---|
Also used internally:
__className__ handle events _change_data lastToggle events olddisplay
Changed October 15, 2010 04:09AM UTC by comment:3
| 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.
Changed October 17, 2010 09:28PM UTC by comment:4
| milestone: | 1.4.4 → 1.5 |
|---|
Retargeting to 1.5.
Changed November 08, 2010 09:31PM UTC by comment:5
| keywords: | → needstests, patch |
|---|
Changed November 19, 2010 01:19PM UTC by comment:6
| keywords: | needstests, patch → needstest patch |
|---|
Changed November 30, 2010 10:32AM UTC by comment:7
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
Changed December 18, 2010 05:16PM UTC by comment:8
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.
Changed December 28, 2010 05:55PM UTC by comment:10
| blocking: | → 7840 |
|---|
Changed January 01, 2011 03:07AM UTC by comment:11
| owner: | → snover |
|---|---|
| status: | open → assigned |
Changed January 10, 2011 11:40PM UTC by comment:12
Replying to [comment:8 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.
Changed January 10, 2011 11:52PM UTC by comment:13
pull request i forgot to put this here.
Changed January 17, 2011 09:33PM UTC by comment:14
| 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.