Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
a5e407ca
Commit
a5e407ca
authored
May 10, 2011
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that data properties with hyphens are always accessed/set using camelCase. Fixes #9124.
parent
419b5e5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
data.js
src/data.js
+2
-2
data.js
test/unit/data.js
+7
-2
No files found.
src/data.js
View file @
a5e407ca
...
...
@@ -98,7 +98,7 @@ jQuery.extend({
}
if
(
data
!==
undefined
)
{
thisCache
[
name
]
=
data
;
thisCache
[
jQuery
.
camelCase
(
name
)
]
=
data
;
}
// TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
...
...
@@ -108,7 +108,7 @@ jQuery.extend({
return
thisCache
[
internalKey
]
&&
thisCache
[
internalKey
].
events
;
}
return
getByName
?
thisCache
[
name
]
:
thisCache
;
return
getByName
?
thisCache
[
jQuery
.
camelCase
(
name
)
]
:
thisCache
;
},
removeData
:
function
(
elem
,
name
,
pvt
/* Internal Use Only */
)
{
...
...
test/unit/data.js
View file @
a5e407ca
...
...
@@ -488,7 +488,7 @@ if (window.JSON && window.JSON.stringify) {
}
test
(
"jQuery.data should follow html5 specification regarding camel casing"
,
function
()
{
expect
(
6
);
expect
(
8
);
var
div
=
jQuery
(
"<div id='myObject' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>"
)
.
prependTo
(
"body"
);
...
...
@@ -501,5 +501,10 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
equals
(
div
.
data
(
"fooBar"
),
"b"
,
"Verify multiple word data-* key"
);
equals
(
div
.
data
(
"fooBarBaz"
),
"c"
,
"Verify multiple word data-* key"
);
div
.
data
(
"foo-bar"
,
"d"
);
equals
(
div
.
data
(
"fooBar"
),
"d"
,
"Verify updated data-* key"
);
equals
(
div
.
data
(
"foo-bar"
),
"d"
,
"Verify updated data-* key"
);
div
.
remove
();
});
\ No newline at end of file
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment