Core: Support non-browser environments

Fixes gh-2133
Fixes gh-2501
Closes gh-2504
Refs gh-1950
Refs gh-1949
Refs gh-2397
Refs gh-1537
Refs gh-2504
Refs 842958e7ae
This commit is contained in:
Michał Gołębiowski
2015-07-28 12:58:44 +02:00
parent 9b04201ff2
commit 04ec688e80
45 changed files with 363 additions and 68 deletions

View File

@@ -1,11 +1,12 @@
define([
"exports",
"../core",
"../var/documentElement",
"./var/rnumnonpx",
"./var/rmargin",
"./support",
"../selector" // contains
], function( exports, jQuery, rnumnonpx, rmargin, support ) {
], function( exports, jQuery, documentElement, rnumnonpx, rmargin, support ) {
var getStyles, curCSS,
rposition = /^(top|right|bottom|left)$/;
@@ -68,7 +69,7 @@ if ( window.getComputedStyle ) {
ret :
ret + "";
};
} else if ( document.documentElement.currentStyle ) {
} else if ( documentElement.currentStyle ) {
getStyles = function( elem ) {
return elem.currentStyle;
};

View File

@@ -1,32 +1,30 @@
define([
"../core",
"../var/document",
"../var/documentElement",
"../var/support"
], function( jQuery, support ) {
], function( jQuery, document, documentElement, support ) {
(function() {
var div, container, style, a, pixelPositionVal, boxSizingReliableVal, gBCRDimensionsVal,
pixelMarginRightVal, reliableHiddenOffsetsVal, reliableMarginRightVal;
// Setup
div = document.createElement( "div" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
a = div.getElementsByTagName( "a" )[ 0 ];
style = a && a.style;
var pixelPositionVal, boxSizingReliableVal, gBCRDimensionsVal,
pixelMarginRightVal, reliableHiddenOffsetsVal, reliableMarginRightVal,
container = document.createElement( "div" ),
div = document.createElement( "div" );
// Finish early in limited (non-browser) environments
if ( !style ) {
if ( !div.style ) {
return;
}
style.cssText = "float:left;opacity:.5";
div.style.cssText = "float:left;opacity:.5";
// Support: IE<9
// Make sure that element opacity exists (as opposed to filter)
support.opacity = style.opacity === "0.5";
support.opacity = div.style.opacity === "0.5";
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
support.cssFloat = !!style.cssFloat;
support.cssFloat = !!div.style.cssFloat;
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";