src/aria/utils/Dom.js
function (element, property) {
            var browser = ariaCoreBrowser;
            var isIE8orLess = browser.isIE8 || browser.isIE7;
            if (isIE8orLess) {
                this.getStyle = function (element, property) {
                    if (property == 'opacity') {// IE<=8 opacity uses filter
                        var val = 100;
                        try { // will error if no DXImageTransform
                            val = element.filters['DXImageTransform.Microsoft.Alpha'].opacity;
                        } catch (e) {
                            try { // make sure its in the document
                                val = element.filters('alpha').opacity;
                            } catch (er) {}
                        }
                        return (val / 100).toString(10); // to be consistent with getComputedStyle
                    } else if (property == 'width' || property == 'height') {
                        return ariaUtilsCssUnits.getDomWidthOrHeightForOldIE(element, property);
                    } else if (property == 'float') { // fix reserved word
                        property = 'styleFloat'; // fall through
                    }
                    var value;
                    // test currentStyle before touching
                    if (element.currentStyle) {
                        value = element.currentStyle[property];
                        if (!value) {
                            // Try the camel case
                            var camel = ariaUtilsString.dashedToCamel(property);
                            value = element.currentStyle[camel];
                        }
                    }
                    return (value || element.style[property]);
                };
            } else {
                this.getStyle = function (element, property) {
                    var window = Aria.$window;
                    var value = null;
                    if (property == "float") {
                        property = "cssFloat";
                    } else if (property == "backgroundPositionX" || property == "backgroundPositionY") {
                        // backgroundPositionX and backgroundPositionY are not standard
                        var backgroundPosition = this.getStyle(element, "backgroundPosition");
                        if (backgroundPosition) {
                            var match = /^([-.0-9a-z%]+)\s([-.0-9a-z%]+)($|,)/.exec(backgroundPosition);
                            if (match) {
                                value = ((property == "backgroundPositionX") ? match[1] : match[2]);
                            }
                        }
                        return value;
                    }
                    var computed = window.getComputedStyle(element, "");
                    if (computed) {
                        value = computed[property];
                    }
                    return (value || element.style[property]);
                };
            }

            return this.getStyle(element, property);
        }
function (element, property) {
            var browser = ariaCoreBrowser;
            var isIE8orLess = browser.isIE8 || browser.isIE7;
            if (isIE8orLess) {
                this.getStyle = function (element, property) {
                    if (property == 'opacity') {// IE<=8 opacity uses filter
                        var val = 100;
                        try { // will error if no DXImageTransform
                            val = element.filters['DXImageTransform.Microsoft.Alpha'].opacity;
                        } catch (e) {
                            try { // make sure its in the document
                                val = element.filters('alpha').opacity;
                            } catch (er) {}
                        }
                        return (val / 100).toString(10); // to be consistent with getComputedStyle
                    } else if (property == 'width' || property == 'height') {
                        return ariaUtilsCssUnits.getDomWidthOrHeightForOldIE(element, property);
                    } else if (property == 'float') { // fix reserved word
                        property = 'styleFloat'; // fall through
                    }
                    var value;
                    // test currentStyle before touching
                    if (element.currentStyle) {
                        value = element.currentStyle[property];
                        if (!value) {
                            // Try the camel case
                            var camel = ariaUtilsString.dashedToCamel(property);
                            value = element.currentStyle[camel];
                        }
                    }
                    return (value || element.style[property]);
                };
            } else {
                this.getStyle = function (element, property) {
                    var window = Aria.$window;
                    var value = null;
                    if (property == "float") {
                        property = "cssFloat";
                    } else if (property == "backgroundPositionX" || property == "backgroundPositionY") {
                        // backgroundPositionX and backgroundPositionY are not standard
                        var backgroundPosition = this.getStyle(element, "backgroundPosition");
                        if (backgroundPosition) {
                            var match = /^([-.0-9a-z%]+)\s([-.0-9a-z%]+)($|,)/.exec(backgroundPosition);
                            if (match) {
                                value = ((property == "backgroundPositionX") ? match[1] : match[2]);
                            }
                        }
                        return value;
                    }
                    var computed = window.getComputedStyle(element, "");
                    if (computed) {
                        value = computed[property];
                    }
                    return (value || element.style[property]);
                };
            }

            return this.getStyle(element, property);
        }
function ( element , property ) { var browser = ariaCoreBrowser ; var isIE8orLess = browser . isIE8 || browser . isIE7 ; if ( isIE8orLess ) { this . getStyle = function ( element , property ) { if ( property == 'opacity' ) { // IE<=8 opacity uses filter var val = 100 ; try { // will error if no DXImageTransform val = element . filters [ 'DXImageTransform.Microsoft.Alpha' ] . opacity ; } catch ( e ) { try { // make sure its in the document val = element . filters ( 'alpha' ) . opacity ; } catch ( er ) { } } return ( val / 100 ) . toString ( 10 ) ; // to be consistent with getComputedStyle } else if ( property == 'width' || property == 'height' ) { return ariaUtilsCssUnits . getDomWidthOrHeightForOldIE ( element , property ) ; } else if ( property == 'float' ) { // fix reserved word property = 'styleFloat' ; // fall through } var value ; // test currentStyle before touching if ( element . currentStyle ) { value = element . currentStyle [ property ] ; if ( ! value ) { // Try the camel case var camel = ariaUtilsString . dashedToCamel ( property ) ; value = element . currentStyle [ camel ] ; } } return ( value || element . style [ property ] ) ; } ; } else { this . getStyle = function ( element , property ) { var window = Aria . $window ; var value = null ; if ( property == "float" ) { property = "cssFloat" ; } else if ( property == "backgroundPositionX" || property == "backgroundPositionY" ) { // backgroundPositionX and backgroundPositionY are not standard var backgroundPosition = this . getStyle ( element , "backgroundPosition" ) ; if ( backgroundPosition ) { var match = / ^([-.0-9a-z%]+)\s([-.0-9a-z%]+)($|,) / . exec ( backgroundPosition ) ; if ( match ) { value = ( ( property == "backgroundPositionX" ) ? match [ 1 ] : match [ 2 ] ) ; } } return value ; } var computed = window . getComputedStyle ( element , "" ) ; if ( computed ) { value = computed [ property ] ; } return ( value || element . style [ property ] ) ; } ; } return this . getStyle ( element , property ) ; }
Retrieve the computed style for a given CSS property on a given DOM element.
@param {HTMLElement} element The DOM element on which to retrieve a CSS property
@param {String} property The CSS property to retrieve. For maximum portability, it should be in camel case
(for instance <code>backgroundImage</code>)
Retrieve the computed style for a given CSS property on a given DOM element .