Skip to content

Commit

Permalink
testStyle madness!
Browse files Browse the repository at this point in the history
- Now this baby will inject and element and the style property and value will be prefixed in all possible combinations
- Works on detecting support for things like image-rendering: -moz-crisp-edges;

      ___
     /___\_/
     |\_/|<\
     (`o`) `   __(\_            |\_
     \ ~ /_.-`` _|__)  ( ( ( ( /()/
    _/`-`  _.-``               `\|
 .-`      (    .-.            _          _ _   ___  _      _____  __
(   .-     \  /   `-._       | |        | | | / __|| | /`|| ____||  \
 \  (\_    /\/        `-.__-()\ \      / /| || /   | |/ / | |__  | | \
  `-|__)__/ /  /``-.   /_____8 \ \_/\_/ / | |||    |   /  |  __| | |\ \
        \__/  /     `-`      `  \      /  | || \__ | |\`\ | |___ | |_| |
       />|   /(         /|(      \_/\_/   |_| \___||_| \_\|_____||_____|
      /| J   L \-.     J J \-.    (         /|      |\      /|)
      `` |   |  \ `\   | |  `\`\   \-.     J J     J  `-..-` |`\-._
         L___J   L  \  L |   J  L   \ `\   | |  _.<.-`-._   /   \  `-.
          ( |    | \ `/  |   |  |    L  \  L | `         L|`     L  \ `\
         .oO()  J  .\    |   L  J    | \ `/  |           ||      |  |\  \
             _.<.-`  `\  |  J    L  J  .\    |  /       J )     J   LJ   L
            `          \ |  |    |.<.-`  `\  | |(.__..-` /     /__..--.  |
                        \|  L____J         \ | |       _/  `--``       `\|
                         )                  \|  \   .-`                  )
                                             )   |/`
                                                 )
  • Loading branch information
ryanseddon committed May 23, 2011
1 parent 5d04648 commit 103b5de
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions modernizr.js
Expand Up @@ -118,17 +118,26 @@ window.Modernizr = (function( window, document, undefined ) {

// Test CSS property and value by injecting element with styles and testing computed style
testStyle = function( prop, value ) {
var prefixed = prefixes.join(prop + ':' + value + ';');

var prefixed = '',
len = prefixes.length,
curProp;

while(len--) {
curProp = prefixes[len]+prop;
prefixed += (curProp + ':' + prefixes.join(value + ';' + curProp + ':')).slice(0, -curProp.length-1);
}

return injectElementWithStyles('#modernizr { '+prefixed+' }',function(elem){
for(var i = 0; i<prefixes.length; i++) {
if(window.getComputedStyle ?
// Some computed properties don't work when accessing through array ,getPropertyValue will work instead
getComputedStyle(elem, null).getPropertyValue(prefixes[i] + prop) :
// some values are camelcase but when returned as computed style are lowercase
elem.currentStyle[prefixes[i] + prop] == value.toLowerCase()) {
return true;
break;
for(var i = 0, len = prefixes.length; i<len; i++) {
for(var k = 0; k<len; k++) {
if((window.getComputedStyle ?
// Some computed properties don't work when accessing through array, getPropertyValue will work instead.
getComputedStyle(elem, null).getPropertyValue(prefixes[i] + prop) :
// some values are camelcase but when returned, as a computed style, are lowercase.
elem.currentStyle[prefixes[i] + prop]) == prefixes[k] + value.toLowerCase()) {
return true;
break;
}
}
}
});
Expand Down

0 comments on commit 103b5de

Please sign in to comment.