Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb35be5

Browse files
authored
Tests: Remove obsolete jQuery data tests
The tests relied on `jQuery.cache` so they only ever worked in jQuery 1.x.Closesgh-4586
1 parent9e66fe9 commiteb35be5

File tree

4 files changed

+0
-115
lines changed

4 files changed

+0
-115
lines changed

‎test/data/testrunner.js

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -21,74 +21,6 @@ QUnit.config.testTimeout = 60e3; // 1 minute
2121
// Enforce an "expect" argument or expect() call in all test bodies.
2222
QUnit.config.requireExpects=true;
2323

24-
/**
25-
*@param {jQuery|HTMLElement|Object|Array} elems Target (or array of targets) for jQuery.data.
26-
*@param {string} key
27-
*/
28-
QUnit.assert.expectJqData=function(env,elems,key){
29-
vari,elem,expando;
30-
31-
// As of jQuery 2.0, there will be no "cache"-data is
32-
// stored and managed completely below the API surface
33-
if(jQuery.cache){
34-
env.checkJqData=true;
35-
36-
if(elems.jquery&&elems.toArray){
37-
elems=elems.toArray();
38-
}
39-
if(!Array.isArray(elems)){
40-
elems=[elems];
41-
}
42-
43-
for(i=0;i<elems.length;i++){
44-
elem=elems[i];
45-
46-
// jQuery.data only stores data for nodes in jQuery.cache,
47-
// for other data targets the data is stored in the object itself,
48-
// in that case we can't test that target for memory leaks.
49-
// But we don't have to since in that case the data will/must will
50-
// be available as long as the object is not garbage collected by
51-
// the js engine, and when it is, the data will be removed with it.
52-
if(!elem.nodeType){
53-
54-
// Fixes false positives for dataTests(window), dataTests({}).
55-
continue;
56-
}
57-
58-
expando=elem[jQuery.expando];
59-
60-
if(expando===undefined){
61-
62-
// In this case the element exists fine, but
63-
// jQuery.data (or internal data) was never (in)directly
64-
// called.
65-
// Since this method was called it means some data was
66-
// expected to be found, but since there is nothing, fail early
67-
// (instead of in teardown).
68-
this.notStrictEqual(
69-
expando,
70-
undefined,
71-
"Target for expectJqData must have an expando, "+
72-
"for else there can be no data to expect."
73-
);
74-
}else{
75-
if(expectedDataKeys[expando]){
76-
expectedDataKeys[expando].push(key);
77-
}else{
78-
expectedDataKeys[expando]=[key];
79-
}
80-
}
81-
}
82-
}
83-
84-
};
85-
QUnit.config.urlConfig.push({
86-
id:"jqdata",
87-
label:"Always check jQuery.data",
88-
tooltip:"Trigger QUnit.expectJqData detection for all tests "+
89-
"instead of just the ones that call it"
90-
});
91-
9224
/**
9325
* Ensures that tests have cleaned up properly after themselves. Should be passed as the
9426
* teardown function on all modules' lifecycle object.
@@ -97,30 +29,6 @@ window.moduleTeardown = function( assert ) {
9729
vari,expectedKeys,actualKeys,
9830
cacheLength=0;
9931

100-
// Only look for jQuery data problems if this test actually
101-
// provided some information to compare against.
102-
if(QUnit.urlParams.jqdata||this.checkJqData){
103-
for(iinjQuery.cache){
104-
expectedKeys=expectedDataKeys[i];
105-
actualKeys=jQuery.cache[i] ?Object.keys(jQuery.cache[i]) :jQuery.cache[i];
106-
if(!QUnit.equiv(expectedKeys,actualKeys)){
107-
assert.deepEqual(actualKeys,expectedKeys,"Expected keys exist in jQuery.cache");
108-
}
109-
deletejQuery.cache[i];
110-
deleteexpectedDataKeys[i];
111-
}
112-
113-
// In case it was removed from cache before (or never there in the first place)
114-
for(iinexpectedDataKeys){
115-
assert.deepEqual(
116-
expectedDataKeys[i],
117-
undefined,
118-
"No unexpected keys were left in jQuery.cache (#"+i+")"
119-
);
120-
deleteexpectedDataKeys[i];
121-
}
122-
}
123-
12432
// Reset data register
12533
expectedDataKeys={};
12634

‎test/unit/attributes.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,10 +1411,6 @@ var testToggleClass = function( valueObj, assert ) {
14111411
e.toggleClass(false);
14121412
e.toggleClass();
14131413
assert.ok(e.is(".testD.testE"),"Assert class present (restored from data)");
1414-
1415-
// Cleanup
1416-
e.removeClass("testD");
1417-
assert.expectJqData(this,e[0],"__className__");
14181414
};
14191415

14201416
QUnit.test("toggleClass(String|boolean|undefined[, boolean])",function(assert){

‎test/unit/data.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ QUnit.test( "jQuery.data(div)", function( assert ) {
132132
vardiv=document.createElement("div");
133133

134134
dataTests(div,assert);
135-
136-
// We stored one key in the private data
137-
// assert that nothing else was put in there, and that that
138-
// one stayed there.
139-
assert.expectJqData(this,div,"foo");
140135
});
141136

142137
QUnit.test("jQuery.data({})",function(assert){
@@ -159,8 +154,6 @@ QUnit.test( "jQuery.data(document)", function( assert ) {
159154
assert.expect(25);
160155

161156
dataTests(document,assert);
162-
163-
assert.expectJqData(this,document,"foo");
164157
});
165158

166159
QUnit.test("jQuery.data(<embed>)",function(assert){

‎test/unit/effects.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ QUnit.test( "show()", function( assert ) {
9090
assert.ok(pass,"Show with "+name+" does not call animate callback");
9191
});
9292

93-
// Tolerate data from show()/hide()
94-
assert.expectJqData(this,div,"olddisplay");
95-
9693
jQuery(
9794
"<div id='show-tests'>"+
9895
"<div><p><a href='#'></a></p><code></code><pre></pre><span></span></div>"+
@@ -217,8 +214,6 @@ supportjQuery.each( hideOptions, function( type, setup ) {
217214
});
218215

219216
clock.tick(300);
220-
221-
assert.expectJqData(this,$span,"olddisplay");
222217
});
223218

224219
// Support: IE 11+, Edge 12 - 18+
@@ -251,8 +246,6 @@ supportjQuery.each( hideOptions, function( type, setup ) {
251246
});
252247

253248
clock.tick(300);
254-
255-
assert.expectJqData(this,$shadowChild,"olddisplay");
256249
});
257250
});
258251

@@ -1161,9 +1154,6 @@ QUnit.test( "interrupt toggle", function( assert ) {
11611154

11621155
// Save original property value for comparison
11631156
jQuery.data(this,"startVal",jQuery(this).css(prop));
1164-
1165-
// Expect olddisplay data from our .hide() call below
1166-
assert.expectJqData(env,this,"olddisplay");
11671157
});
11681158

11691159
// Interrupt a hiding toggle
@@ -1613,8 +1603,6 @@ QUnit.test( "animate should set display for disconnected nodes", function( asser
16131603
assert.strictEqual($divInline.show()[0].style.display,"inline",
16141604
"show() should not change display if it already set");
16151605

1616-
assert.expectJqData(env,$divNone[0],"olddisplay");
1617-
16181606
jQuery.each(showMethods,function(name,opt){
16191607
jQuery.fn[name].apply(jQuery("<div/>"),opt.concat([function(){
16201608
assert.strictEqual(jQuery(this).css("display"),nullParentDisplay,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp