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
d5d4e4df
Commit
d5d4e4df
authored
Sep 21, 2010
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaked the data number RegExp some to handle some other edge cases.
parent
4a46f3d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
data.js
src/data.js
+1
-1
data.js
test/unit/data.js
+5
-1
No files found.
src/data.js
View file @
d5d4e4df
(
function
(
jQuery
)
{
(
function
(
jQuery
)
{
var
windowData
=
{},
var
windowData
=
{},
rnum
=
/^-
?
[
0-9.
]
+
$/
;
rnum
=
/^-
?
\d
+
(?:\.\d
+
)
$/
;
jQuery
.
extend
({
jQuery
.
extend
({
cache
:
{},
cache
:
{},
...
...
test/unit/data.js
View file @
d5d4e4df
...
@@ -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
0
);
expect
(
2
2
);
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>"
);
...
@@ -184,6 +184,8 @@ test("data-* attributes", function() {
...
@@ -184,6 +184,8 @@ test("data-* attributes", function() {
.
attr
(
"data-false"
,
"false"
)
.
attr
(
"data-false"
,
"false"
)
.
attr
(
"data-five"
,
"5"
)
.
attr
(
"data-five"
,
"5"
)
.
attr
(
"data-point"
,
"5.5"
)
.
attr
(
"data-point"
,
"5.5"
)
.
attr
(
"data-pointbad"
,
"5..5"
)
.
attr
(
"data-pointbad2"
,
"-."
)
.
attr
(
"data-null"
,
"null"
)
.
attr
(
"data-null"
,
"null"
)
.
attr
(
"data-string"
,
"test"
);
.
attr
(
"data-string"
,
"test"
);
...
@@ -191,6 +193,8 @@ test("data-* attributes", function() {
...
@@ -191,6 +193,8 @@ test("data-* attributes", function() {
equals
(
child
.
data
(
'false'
),
false
,
"Primitive false read from attribute"
);
equals
(
child
.
data
(
'false'
),
false
,
"Primitive false read from attribute"
);
equals
(
child
.
data
(
'five'
),
5
,
"Primitive number read from attribute"
);
equals
(
child
.
data
(
'five'
),
5
,
"Primitive number read from attribute"
);
equals
(
child
.
data
(
'point'
),
5.5
,
"Primitive number read from attribute"
);
equals
(
child
.
data
(
'point'
),
5.5
,
"Primitive 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
(
'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"
);
...
...
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