Side navigation
#10194 closed bug (fixed)
Opened September 02, 2011 04:44PM UTC
Closed September 07, 2011 02:26PM UTC
Last modified March 08, 2012 11:06PM UTC
Data attribute names with single dash-surrounded letters cannot be accessed by the camel-case name
Reported by: | Pointy | Owned by: | rwaldron |
---|---|---|---|
Priority: | blocker | Milestone: | 1.6.4 |
Component: | data | Version: | 1.6.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Data attributes like "data-image-x-offset" should be accessible via ".data('imageXOffset')", but currently they cannot be. The ".camelCase()" function correctly translates the name, but the code that goes the other direction apparently mishandles this case.
Access by the dashed form of the name works of course.
Attachments (0)
Change History (10)
Changed September 02, 2011 04:56PM UTC by comment:1
Changed September 02, 2011 04:57PM UTC by comment:2
And here's a fiddle: http://jsfiddle.net/99eQ8/
Changed September 02, 2011 06:34PM UTC by comment:3
component: | unfiled → data |
---|---|
milestone: | None → 1.7 |
priority: | undecided → blocker |
status: | new → open |
Confirmed, it's a bug in rmultiDash
. Thanks ... I wish we would have been able to fix this in 1.6.3 but at this point it's a 1.7 item.
Changed September 02, 2011 06:39PM UTC by comment:4
status: | open → reopened |
---|
Changed September 02, 2011 06:39PM UTC by comment:5
owner: | → rwaldron |
---|---|
status: | reopened → assigned |
Changed September 02, 2011 07:01PM UTC by comment:6
Possible solution is:
rmultiDash = /\\B([A-Z])/g; key.replace( newMultiDash, '-$1' ).toLowerCase()
Because it is a single character match, the index of the starting character of the next attempted match will always be one higher than the index of the previous ''starting'' character rather than being one higher than the index of the ''ending'' character matched in the previous match.
Changed September 02, 2011 07:03PM UTC by comment:7
Or I should have said "...rather than being ''two'' higher than the index of the previous starting character if the previous attempt resulted in a match".
Changed September 02, 2011 07:20PM UTC by comment:8
Changed September 03, 2011 09:38PM UTC by comment:9
milestone: | 1.7 → 1.6.4 |
---|
Changed September 07, 2011 02:26PM UTC by comment:10
resolution: | → fixed |
---|---|
status: | assigned → closed |
Bug in rmultidash. Fixes #10194
Changeset: 8e8fa6dc1ad514b0fa20e41faddcb85693d0408a
More info: if the dashed form of the attribute name is used at least once for a given element, then the camel-case form subsequently works.