Commit f7ee1f6e authored by Rick Waldron's avatar Rick Waldron

Update document.defaultView.getComputedStyle. Fixes #10373

parent ab542c11
...@@ -274,15 +274,17 @@ jQuery.extend({ ...@@ -274,15 +274,17 @@ jQuery.extend({
} }
}); });
if ( document.defaultView && document.defaultView.getComputedStyle ) { // NOTE: To any future maintainer, we've used both window.getComputedStyle
// and window.getComputedStyle here to produce a better gzip size
if ( window.getComputedStyle ) {
curCSS = function( elem, name ) { curCSS = function( elem, name ) {
var ret, defaultView, computedStyle, width, var ret, width,
computed = getComputedStyle( elem, null ),
style = elem.style; style = elem.style;
if ( (defaultView = elem.ownerDocument.defaultView) && if ( computed ) {
(computedStyle = defaultView.getComputedStyle( elem, null )) ) {
ret = computedStyle[ name ]; ret = computed[ name ];
if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
ret = jQuery.style( elem, name ); ret = jQuery.style( elem, name );
} }
...@@ -293,7 +295,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { ...@@ -293,7 +295,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
if ( !jQuery.support.pixelMargin && rmargin.test( name ) && rnumnonpx.test( ret ) ) { if ( !jQuery.support.pixelMargin && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
width = style.width; width = style.width;
style.width = ret; style.width = ret;
ret = computedStyle.width; ret = computed.width;
style.width = width; style.width = width;
} }
} }
......
...@@ -210,6 +210,11 @@ jQuery.support = (function() { ...@@ -210,6 +210,11 @@ jQuery.support = (function() {
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
support.boxSizing = ( div.offsetWidth === 4 ); support.boxSizing = ( div.offsetWidth === 4 );
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
// NOTE: To any future maintainer, window.getComputedStyle was used here
// instead of getComputedStyle because it gave a better gzip size.
// The difference between window.getComputedStyle and getComputedStyle is
// 7 bytes
if ( window.getComputedStyle ) { if ( window.getComputedStyle ) {
support.pixelMargin = ( window.getComputedStyle( div, null ) || {} ).marginTop !== "1%"; support.pixelMargin = ( window.getComputedStyle( div, null ) || {} ).marginTop !== "1%";
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment