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
3212a293
Commit
3212a293
authored
Mar 02, 2013
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #13548. .data should not miss attr() set data-* with hyphenated property names
parent
9f981c84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
data.js
src/data.js
+8
-0
data.js
test/unit/data.js
+12
-1
No files found.
src/data.js
View file @
3212a293
...
@@ -264,6 +264,14 @@ jQuery.fn.extend({
...
@@ -264,6 +264,14 @@ jQuery.fn.extend({
if
(
data
!==
undefined
)
{
if
(
data
!==
undefined
)
{
return
data
;
return
data
;
}
}
// Attempt to get data from the cache
// with the key camelized
data
=
data_user
.
get
(
elem
,
camelKey
);
if
(
data
!==
undefined
)
{
return
data
;
}
// Attempt to "discover" the data in
// Attempt to "discover" the data in
// HTML5 custom data-* attrs
// HTML5 custom data-* attrs
data
=
dataAttr
(
elem
,
key
,
undefined
);
data
=
dataAttr
(
elem
,
key
,
undefined
);
...
...
test/unit/data.js
View file @
3212a293
...
@@ -497,7 +497,7 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
...
@@ -497,7 +497,7 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
div
.
remove
();
div
.
remove
();
});
});
test
(
"
jQuery.data should not miss data with preset
hyphenated property names"
,
function
()
{
test
(
"
.data should not miss preset data-* w/
hyphenated property names"
,
function
()
{
expect
(
2
);
expect
(
2
);
...
@@ -514,6 +514,17 @@ test("jQuery.data should not miss data with preset hyphenated property names", f
...
@@ -514,6 +514,17 @@ test("jQuery.data should not miss data with preset hyphenated property names", f
});
});
});
});
test
(
".data should not miss attr() set data-* with hyphenated property names"
,
function
()
{
expect
(
1
);
var
div
=
jQuery
(
"<div/>"
).
appendTo
(
"#qunit-fixture"
);
div
.
attr
(
"data-long-param"
,
"test"
);
div
.
data
(
"long-param"
,
{
a
:
2
});
deepEqual
(
div
.
data
(
"long-param"
),
{
a
:
2
},
"data with property long-param was found"
);
});
test
(
"jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values"
,
function
()
{
test
(
"jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values"
,
function
()
{
var
div
=
jQuery
(
"<div/>"
,
{
id
:
"hyphened"
}).
appendTo
(
"#qunit-fixture"
),
var
div
=
jQuery
(
"<div/>"
,
{
id
:
"hyphened"
}).
appendTo
(
"#qunit-fixture"
),
...
...
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