Permalink
Show file tree
Hide file tree
1 comment
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Remove offset dependency from css. Move curCSS and getStyles to their…
… own modules. -39 bytes. Close gh-1360.
- Loading branch information
Showing
6 changed files
with
111 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
define([ | ||
"../core", | ||
"./var/rnumnonpx", | ||
"./var/rmargin", | ||
"./var/getStyles", | ||
"../css", // Circular, but needs jQuery.style | ||
"../selector" // contains | ||
], function( jQuery, rnumnonpx, rmargin, getStyles ) { | ||
|
||
function curCSS( elem, name, computed ) { | ||
var width, minWidth, maxWidth, ret, | ||
style = elem.style; | ||
|
||
computed = computed || getStyles( elem ); | ||
|
||
// Support: IE9 | ||
// getPropertyValue is only needed for .css('filter') in IE9, see #12537 | ||
ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; | ||
|
||
if ( computed ) { | ||
|
||
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { | ||
ret = jQuery.style( elem, name ); | ||
} | ||
|
||
// Support: iOS < 6 | ||
// A tribute to the "awesome hack by Dean Edwards" | ||
// iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels | ||
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values | ||
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { | ||
|
||
// Remember the original values | ||
width = style.width; | ||
minWidth = style.minWidth; | ||
maxWidth = style.maxWidth; | ||
|
||
// Put in the new values to get a computed value out | ||
style.minWidth = style.maxWidth = style.width = ret; | ||
ret = computed.width; | ||
|
||
// Revert the changed values | ||
style.width = width; | ||
style.minWidth = minWidth; | ||
style.maxWidth = maxWidth; | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
return curCSS; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
define(function() { | ||
return function( elem ) { | ||
return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
define(function() { | ||
return (/^margin/); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
define([ | ||
"../../var/pnum" | ||
], function( pnum ) { | ||
return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4ded9be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil Remember to cherry-pick this commit to
1.x-master
as well.