Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"grunt-jsonlint": "1.0.4",
"grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2",
"jsdom": "1.5.0",
"jsdom": "3.1.2",
"load-grunt-tasks": "1.0.0",
"native-promise-only": "0.7.8-a",
"npm": "2.1.12",
Expand Down
11 changes: 3 additions & 8 deletions src/core/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ define([
], function( document, support ) {

support.createHTMLDocument = (function() {
var doc = document.implementation.createHTMLDocument( "" );
// Support: Node with jsdom<=1.5.0+
// jsdom's document created via the above method doesn't contain the body
if ( !doc.body ) {
return false;
}
doc.body.innerHTML = "<form></form><form></form>";
return doc.body.childNodes.length === 2;
var body = document.implementation.createHTMLDocument( "" ).body;
body.innerHTML = "<form></form><form></form>";
return body.childNodes.length === 2;
})();

return support;
Expand Down
94 changes: 45 additions & 49 deletions src/css/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,61 +46,57 @@ define([
documentElement.removeChild( container );
}

// Support: node.js jsdom
// Don't assume that getComputedStyle is a property of the global object
if ( window.getComputedStyle ) {
jQuery.extend( support, {
pixelPosition: function() {
// This test is executed only once but we still do memoizing
// since we can use the boxSizingReliable pre-computing.
// No need to check if the test was already performed, though.
jQuery.extend( support, {
pixelPosition: function() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment didn't make sense even for jsdom 1.5. Were there any other reasons to hide these support tests? Are we worried about other envs that will expose window without getComputedStyle? If so, I'll revert but the comment will need to be changed completely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it comes into play here, but window may be a non-Window global object: https://github.com/mzgol/jquery/blob/jsdom-update/src/intro.js#L38

In any case, the comment probably does need rewriting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to say getComputedStyle assuming that was in the global scope. So it was more about assuming window and global were equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, window is not a global here but what was passed to the factory. Unless the global has a property document when we assume we're in a browser and assign window = current global.

This works without this if in jsdom because its window parameter has getComputedStyle. Do we want to support anything else here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to get input from more people here as I'm a little afraid of this change. cc @jquery/core

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as getComputedStyle is available, I'm fine with this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as getComputedStyle is available, I'm fine with this.

Great. I'd like to have as many people test it as possible since I'm still worried a little so I'd like to get it into the first beta.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be safe, see 3722aef , dc3f7d3 and http://bugs.jquery.com/ticket/12235 for background.

// This test is executed only once but we still do memoizing
// since we can use the boxSizingReliable pre-computing.
// No need to check if the test was already performed, though.
computeStyleTests();
return pixelPositionVal;
},
boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
computeStyleTests();
return pixelPositionVal;
},
boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
computeStyleTests();
}
return boxSizingReliableVal;
},
pixelMarginRight: function() {
// Support: Android 4.0-4.3
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
// since that compresses better and they're computed together anyway.
if ( boxSizingReliableVal == null ) {
computeStyleTests();
}
return pixelMarginRightVal;
},
reliableMarginRight: function() {
}
return boxSizingReliableVal;
},
pixelMarginRight: function() {
// Support: Android 4.0-4.3
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
// since that compresses better and they're computed together anyway.
if ( boxSizingReliableVal == null ) {
computeStyleTests();
}
return pixelMarginRightVal;
},
reliableMarginRight: function() {

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

// Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
"display:block;margin:0;border:0;padding:0";
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
documentElement.appendChild( container );
// Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
"display:block;margin:0;border:0;padding:0";
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
documentElement.appendChild( container );

ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );

documentElement.removeChild( container );
div.removeChild( marginDiv );
documentElement.removeChild( container );
div.removeChild( marginDiv );

return ret;
}
});
}
return ret;
}
});
})();

return support;
Expand Down