Skip to content
Permalink
Browse files
Streamline getComputedStyle per @JustinDrake's observation.
  • Loading branch information
dmethvin committed Nov 6, 2011
1 parent f35ba5e commit 262c32a70e1f14e5addd263af2f868525aab03c8
Showing 1 changed file with 2 additions and 5 deletions.
@@ -268,11 +268,8 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {

name = name.replace( rupper, "-$1" ).toLowerCase();

if ( !(defaultView = elem.ownerDocument.defaultView) ) {
return undefined;
}

if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
if ( (defaultView = elem.ownerDocument.defaultView) &&
(computedStyle = defaultView.getComputedStyle( elem, null )) ) {
ret = computedStyle.getPropertyValue( name );
if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
ret = jQuery.style( elem, name );

2 comments on commit 262c32a

@mikesherov
Copy link
Member

@mikesherov mikesherov commented on 262c32a Nov 6, 2011

Choose a reason for hiding this comment

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

Actually, instead of inlining it, couldn't you move it above the name = line to avoid unnecessary calcs? Or is the inlining byte saving more important?

@dmethvin
Copy link
Member Author

@dmethvin dmethvin commented on 262c32a Nov 6, 2011

Choose a reason for hiding this comment

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

My guess was that we'll have those two in most situations, so the code to decamelize name will be needed in most cases. Plus the bytes thing.

Please sign in to comment.