Skip to content

Commit 97af1cc

Browse files
committed
Core: Update tested jsdom, drop obsolete workarounds
The latest version supporting Node.js is 3.1.2; some workarounds are not needed for this version. For example, in jsdom 3.1.2 a document created via document.implementation.createHTMLDocument( "" ) has a body. Fixes jquerygh-2153 Closes jquerygh-2154
1 parent 0065e1f commit 97af1cc

File tree

3 files changed

+49
-58
lines changed

3 files changed

+49
-58
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"grunt-jsonlint": "1.0.4",
4343
"grunt-npmcopy": "0.1.0",
4444
"gzip-js": "0.3.2",
45-
"jsdom": "1.5.0",
45+
"jsdom": "3.1.2",
4646
"load-grunt-tasks": "1.0.0",
4747
"native-promise-only": "0.7.7-a",
4848
"npm": "2.1.12",

src/core/support.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ define([
44
], function( document, support ) {
55

66
support.createHTMLDocument = (function() {
7-
var doc = document.implementation.createHTMLDocument( "" );
8-
// Support: Node with jsdom<=1.5.0+
9-
// jsdom's document created via the above method doesn't contain the body
10-
if ( !doc.body ) {
11-
return false;
12-
}
13-
doc.body.innerHTML = "<form></form><form></form>";
14-
return doc.body.childNodes.length === 2;
7+
var body = document.implementation.createHTMLDocument( "" ).body;
8+
body.innerHTML = "<form></form><form></form>";
9+
return body.childNodes.length === 2;
1510
})();
1611

1712
return support;

src/css/support.js

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -46,61 +46,57 @@ define([
4646
documentElement.removeChild( container );
4747
}
4848

49-
// Support: node.js jsdom
50-
// Don't assume that getComputedStyle is a property of the global object
51-
if ( window.getComputedStyle ) {
52-
jQuery.extend( support, {
53-
pixelPosition: function() {
54-
// This test is executed only once but we still do memoizing
55-
// since we can use the boxSizingReliable pre-computing.
56-
// No need to check if the test was already performed, though.
49+
jQuery.extend( support, {
50+
pixelPosition: function() {
51+
// This test is executed only once but we still do memoizing
52+
// since we can use the boxSizingReliable pre-computing.
53+
// No need to check if the test was already performed, though.
54+
computeStyleTests();
55+
return pixelPositionVal;
56+
},
57+
boxSizingReliable: function() {
58+
if ( boxSizingReliableVal == null ) {
5759
computeStyleTests();
58-
return pixelPositionVal;
59-
},
60-
boxSizingReliable: function() {
61-
if ( boxSizingReliableVal == null ) {
62-
computeStyleTests();
63-
}
64-
return boxSizingReliableVal;
65-
},
66-
pixelMarginRight: function() {
67-
// Support: Android 4.0-4.3
68-
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
69-
// since that compresses better and they're computed together anyway.
70-
if ( boxSizingReliableVal == null ) {
71-
computeStyleTests();
72-
}
73-
return pixelMarginRightVal;
74-
},
75-
reliableMarginRight: function() {
60+
}
61+
return boxSizingReliableVal;
62+
},
63+
pixelMarginRight: function() {
64+
// Support: Android 4.0-4.3
65+
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
66+
// since that compresses better and they're computed together anyway.
67+
if ( boxSizingReliableVal == null ) {
68+
computeStyleTests();
69+
}
70+
return pixelMarginRightVal;
71+
},
72+
reliableMarginRight: function() {
7673

77-
// Support: Android 2.3
78-
// Check if div with explicit width and no margin-right incorrectly
79-
// gets computed margin-right based on width of container. (#3333)
80-
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
81-
// This support function is only executed once so no memoizing is needed.
82-
var ret,
83-
marginDiv = div.appendChild( document.createElement( "div" ) );
74+
// Support: Android 2.3
75+
// Check if div with explicit width and no margin-right incorrectly
76+
// gets computed margin-right based on width of container. (#3333)
77+
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
78+
// This support function is only executed once so no memoizing is needed.
79+
var ret,
80+
marginDiv = div.appendChild( document.createElement( "div" ) );
8481

85-
// Reset CSS: box-sizing; display; margin; border; padding
86-
marginDiv.style.cssText = div.style.cssText =
87-
// Support: Android 2.3
88-
// Vendor-prefix box-sizing
89-
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
90-
"display:block;margin:0;border:0;padding:0";
91-
marginDiv.style.marginRight = marginDiv.style.width = "0";
92-
div.style.width = "1px";
93-
documentElement.appendChild( container );
82+
// Reset CSS: box-sizing; display; margin; border; padding
83+
marginDiv.style.cssText = div.style.cssText =
84+
// Support: Android 2.3
85+
// Vendor-prefix box-sizing
86+
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
87+
"display:block;margin:0;border:0;padding:0";
88+
marginDiv.style.marginRight = marginDiv.style.width = "0";
89+
div.style.width = "1px";
90+
documentElement.appendChild( container );
9491

95-
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
92+
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
9693

97-
documentElement.removeChild( container );
98-
div.removeChild( marginDiv );
94+
documentElement.removeChild( container );
95+
div.removeChild( marginDiv );
9996

100-
return ret;
101-
}
102-
});
103-
}
97+
return ret;
98+
}
99+
});
104100
})();
105101

106102
return support;

0 commit comments

Comments
 (0)