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
d1de3000
Commit
d1de3000
authored
Dec 31, 2012
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0: Rewrite data.js
Signed-off-by:
Rick Waldron
<
waldron.rick@gmail.com
>
parent
e1dcf96b
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
286 additions
and
279 deletions
+286
-279
data.js
src/data.js
+189
-220
testrunner.js
test/data/testrunner.js
+62
-53
data.js
test/unit/data.js
+35
-6
No files found.
src/data.js
View file @
d1de3000
This diff is collapsed.
Click to expand it.
test/data/testrunner.js
View file @
d1de3000
...
@@ -200,6 +200,8 @@ var Globals = (function() {
...
@@ -200,6 +200,8 @@ var Globals = (function() {
*/
*/
QUnit
.
expectJqData
=
function
(
elems
,
key
)
{
QUnit
.
expectJqData
=
function
(
elems
,
key
)
{
var
i
,
elem
,
expando
;
var
i
,
elem
,
expando
;
if
(
jQuery
.
cache
)
{
QUnit
.
current_testEnvironment
.
checkJqData
=
true
;
QUnit
.
current_testEnvironment
.
checkJqData
=
true
;
if
(
elems
.
jquery
&&
elems
.
toArray
)
{
if
(
elems
.
jquery
&&
elems
.
toArray
)
{
...
@@ -241,6 +243,8 @@ var Globals = (function() {
...
@@ -241,6 +243,8 @@ var Globals = (function() {
}
}
}
}
}
}
}
};
};
QUnit
.
config
.
urlConfig
.
push
(
{
QUnit
.
config
.
urlConfig
.
push
(
{
id
:
"jqdata"
,
id
:
"jqdata"
,
...
@@ -258,6 +262,7 @@ var Globals = (function() {
...
@@ -258,6 +262,7 @@ var Globals = (function() {
fragmentsLength
=
0
,
fragmentsLength
=
0
,
cacheLength
=
0
;
cacheLength
=
0
;
if
(
jQuery
.
cache
)
{
// Only look for jQuery data problems if this test actually
// Only look for jQuery data problems if this test actually
// provided some information to compare against.
// provided some information to compare against.
if
(
QUnit
.
urlParams
.
jqdata
||
this
.
checkJqData
)
{
if
(
QUnit
.
urlParams
.
jqdata
||
this
.
checkJqData
)
{
...
@@ -279,13 +284,17 @@ var Globals = (function() {
...
@@ -279,13 +284,17 @@ var Globals = (function() {
// Reset data register
// Reset data register
expectedDataKeys
=
{};
expectedDataKeys
=
{};
}
// Allow QUnit.reset to clean up any attached elements before checking for leaks
// Allow QUnit.reset to clean up any attached elements before checking for leaks
QUnit
.
reset
();
QUnit
.
reset
();
if
(
jQuery
.
cache
)
{
for
(
i
in
jQuery
.
cache
)
{
for
(
i
in
jQuery
.
cache
)
{
++
cacheLength
;
++
cacheLength
;
}
}
}
jQuery
.
fragments
=
{};
jQuery
.
fragments
=
{};
...
...
test/unit/data.js
View file @
d1de3000
module
(
"data"
,
{
teardown
:
moduleTeardown
});
module
(
"data"
,
{
teardown
:
moduleTeardown
});
test
(
"expando"
,
function
()
{
test
(
"expando"
,
function
()
{
expect
(
1
);
expect
(
1
);
equal
(
jQuery
.
expando
!==
undefined
,
true
,
"jQuery is exposing the expando"
);
equal
(
jQuery
.
expando
!==
undefined
,
true
,
"jQuery is exposing the expando"
);
});
});
test
(
"jQuery.data & removeData, expected returns"
,
function
()
{
expect
(
2
);
equal
(
jQuery
.
data
(
document
.
body
,
"hello"
,
"world"
),
"world"
,
"jjQuery.data( elem, key, value ) returns value"
);
equal
(
jQuery
.
removeData
(
document
.
body
,
"hello"
),
undefined
,
"jjQuery.removeData( elem, key, value ) returns undefined"
);
});
test
(
"jQuery._data & _removeData, expected returns"
,
function
()
{
expect
(
2
);
equal
(
jQuery
.
_data
(
document
.
body
,
"hello"
,
"world"
),
"world"
,
"jjQuery.data( elem, key, value ) returns value"
);
equal
(
jQuery
.
_removeData
(
document
.
body
,
"hello"
),
undefined
,
"jjQuery.removeData( elem, key, value ) returns undefined"
);
});
function
dataTests
(
elem
)
{
function
dataTests
(
elem
)
{
var
oldCacheLength
,
dataObj
,
internalDataObj
,
expected
,
actual
;
var
oldCacheLength
,
dataObj
,
internalDataObj
,
expected
,
actual
;
...
@@ -99,6 +126,7 @@ test("jQuery.data(document)", 25, function() {
...
@@ -99,6 +126,7 @@ test("jQuery.data(document)", 25, function() {
QUnit
.
expectJqData
(
document
,
"foo"
);
QUnit
.
expectJqData
(
document
,
"foo"
);
});
});
/*
test("Expando cleanup", 4, function() {
test("Expando cleanup", 4, function() {
var expected, actual,
var expected, actual,
div = document.createElement("div");
div = document.createElement("div");
...
@@ -132,7 +160,8 @@ test("Expando cleanup", 4, function() {
...
@@ -132,7 +160,8 @@ test("Expando cleanup", 4, function() {
// Clean up unattached element
// Clean up unattached element
jQuery(div).remove();
jQuery(div).remove();
});
});
*/
/*
test("jQuery.acceptData", function() {
test("jQuery.acceptData", function() {
expect(7);
expect(7);
...
@@ -150,7 +179,7 @@ test("jQuery.acceptData", function() {
...
@@ -150,7 +179,7 @@ test("jQuery.acceptData", function() {
applet.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
applet.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
ok( !jQuery.acceptData( applet ), "applet" );
ok( !jQuery.acceptData( applet ), "applet" );
});
});
*/
test
(
".data()"
,
function
()
{
test
(
".data()"
,
function
()
{
expect
(
5
);
expect
(
5
);
...
@@ -465,8 +494,8 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
...
@@ -465,8 +494,8 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
div
.
data
(
"foo-bar"
,
"d"
);
div
.
data
(
"foo-bar"
,
"d"
);
equal
(
div
.
data
(
"fooBar"
),
"d"
,
"Verify updated data-* key"
);
equal
(
div
.
data
(
"fooBar"
),
"d"
,
"Verify updated data-* key
(fooBar)
"
);
equal
(
div
.
data
(
"foo-bar"
),
"d"
,
"Verify updated data-* key"
);
equal
(
div
.
data
(
"foo-bar"
),
"d"
,
"Verify updated data-* key
(foo-bar)
"
);
div
.
remove
();
div
.
remove
();
});
});
...
...
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