Last active
July 19, 2024 17:38
-
-
Save jackfuchs/556448 to your computer and use it in GitHub Desktop.
Extends the jQuery.support object to CSS Properties
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
/** | |
* jQuery.support.cssProperty | |
* To verify that a CSS property is supported | |
* (or any of its browser-specific implementations) | |
* | |
* @param p css property name | |
* @param rp optional, if set to true, the css property name will be returned | |
* instead of a boolean support indicator | |
* @return {mixed} | |
* | |
* @author: Axel Jack Fuchs (Cologne, Germany) | |
* @date: 08-29-2010 18:43 | |
* @url https://gist.github.com/jackfuchs/556448 | |
* | |
* Example: $.support.cssProperty('boxShadow'); | |
* Returns: true | |
* | |
* Example: $.support.cssProperty('boxShadow', true); | |
* Returns: 'MozBoxShadow' (On Firefox4 beta4) | |
* Returns: 'WebkitBoxShadow' (On Safari 5) | |
*/ | |
$.support.cssProperty = (function() { | |
function cssProperty(p, rp) { | |
var b = document.body || document.documentElement, | |
s = b.style; | |
// No css support detected | |
if (typeof s == 'undefined') { return false; } | |
// Tests for standard prop | |
if (typeof s[p] == 'string') { return rp ? p : true; } | |
// Tests for vendor specific prop | |
var v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms', 'Icab'], | |
p = p.charAt(0).toUpperCase() + p.substr(1), | |
vl = v.length; | |
for (var i=0; i<vl; i++) { | |
if (typeof s[v[i] + p] == 'string') { return rp ? (v[i] + p) : true; } | |
} | |
return false; | |
} | |
return cssProperty; | |
})(); |
Ms
-> ms
Good work. I added a return false;
too.
License?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/*
I do something equal to your work :
this build a $.support.css object with all properties
Xavier Bouhours
*/
(function($)
{
// Extend the jQuery.support with css3 normalized names.
})(jQuery);