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
1f8a5e4b
Commit
1f8a5e4b
authored
Sep 21, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that the data- import also supports arrays.
parent
e7c2d3b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
data.js
src/data.js
+1
-1
data.js
test/unit/data.js
+4
-2
No files found.
src/data.js
View file @
1f8a5e4b
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
var
windowData
=
{},
var
windowData
=
{},
rnum
=
/^-
?\d
+
(?:\.\d
+
)
$/
,
rnum
=
/^-
?\d
+
(?:\.\d
+
)
$/
,
rbrace
=
/^
{.*}
$/
;
rbrace
=
/^
(?:
{.*}|
\[
.*
\])
$/
;
jQuery
.
extend
({
jQuery
.
extend
({
cache
:
{},
cache
:
{},
...
...
test/unit/data.js
View file @
1f8a5e4b
...
@@ -158,7 +158,7 @@ test(".data(String) and .data(String, Object)", function() {
...
@@ -158,7 +158,7 @@ test(".data(String) and .data(String, Object)", function() {
});
});
test
(
"data-* attributes"
,
function
()
{
test
(
"data-* attributes"
,
function
()
{
expect
(
2
3
);
expect
(
2
4
);
var
div
=
jQuery
(
"<div>"
),
var
div
=
jQuery
(
"<div>"
),
child
=
jQuery
(
"<div data-myobj='old data' data-ignored=
\"
DOM
\"
></div>"
);
child
=
jQuery
(
"<div data-myobj='old data' data-ignored=
\"
DOM
\"
></div>"
);
...
@@ -187,6 +187,7 @@ test("data-* attributes", function() {
...
@@ -187,6 +187,7 @@ test("data-* attributes", function() {
.
attr
(
"data-pointbad"
,
"5..5"
)
.
attr
(
"data-pointbad"
,
"5..5"
)
.
attr
(
"data-pointbad2"
,
"-."
)
.
attr
(
"data-pointbad2"
,
"-."
)
.
attr
(
"data-badjson"
,
"{123}"
)
.
attr
(
"data-badjson"
,
"{123}"
)
.
attr
(
"data-badjson2"
,
"[abc]"
)
.
attr
(
"data-null"
,
"null"
)
.
attr
(
"data-null"
,
"null"
)
.
attr
(
"data-string"
,
"test"
);
.
attr
(
"data-string"
,
"test"
);
...
@@ -197,6 +198,7 @@ test("data-* attributes", function() {
...
@@ -197,6 +198,7 @@ test("data-* attributes", function() {
equals
(
child
.
data
(
'pointbad'
),
"5..5"
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'pointbad'
),
"5..5"
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'pointbad2'
),
"-."
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'pointbad2'
),
"-."
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'badjson'
),
"{123}"
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'badjson'
),
"{123}"
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'badjson2'
),
"[abc]"
,
"Bad number read from attribute"
);
equals
(
child
.
data
(
'null'
),
null
,
"Primitive null read from attribute"
);
equals
(
child
.
data
(
'null'
),
null
,
"Primitive null read from attribute"
);
equals
(
child
.
data
(
'string'
),
"test"
,
"Typical string read from attribute"
);
equals
(
child
.
data
(
'string'
),
"test"
,
"Typical string read from attribute"
);
...
@@ -219,7 +221,7 @@ test("data-* attributes", function() {
...
@@ -219,7 +221,7 @@ test("data-* attributes", function() {
break
;
break
;
case
3
:
case
3
:
equals
(
jQuery
(
elem
).
data
(
"number"
),
true
,
"Check number property"
);
equals
(
jQuery
(
elem
).
data
(
"number"
),
true
,
"Check number property"
);
equals
(
jQuery
(
elem
).
data
(
"stuff"
),
"[2,8]"
,
"Check stuff property"
);
same
(
jQuery
(
elem
).
data
(
"stuff"
),
[
2
,
8
]
,
"Check stuff property"
);
break
;
break
;
default
:
default
:
ok
(
false
,
[
"Assertion failed on index "
,
index
,
", with data "
,
data
].
join
(
''
));
ok
(
false
,
[
"Assertion failed on index "
,
index
,
", with data "
,
data
].
join
(
''
));
...
...
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