Sha256: fccb399b8e0c3faec35ae7a5e12f5961b86dd1acd3b6bba7ddb104e446f45b78

Contents?: true

Size: 1.85 KB

Versions: 144

Compression:

Stored size: 1.85 KB

Contents

// Browser support test for the HTML5 <ruby>, <rt> and <rp> elements
// http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-ruby-element
//
// by @alrra

Modernizr.addTest('ruby', function () {

    var ruby = document.createElement('ruby'),
        rt = document.createElement('rt'),
        rp = document.createElement('rp'),
        docElement = document.documentElement,
        displayStyleProperty = 'display',
        fontSizeStyleProperty = 'fontSize'; // 'fontSize' - because it`s only used for IE6 and IE7

    ruby.appendChild(rp);
    ruby.appendChild(rt);
    docElement.appendChild(ruby);

    // browsers that support <ruby> hide the <rp> via "display:none"
    if ( getStyle(rp, displayStyleProperty) == 'none' ||                                                       // for non-IE browsers
    // but in IE browsers <rp> has "display:inline" so, the test needs other conditions:
        getStyle(ruby, displayStyleProperty) == 'ruby' && getStyle(rt, displayStyleProperty) == 'ruby-text' || // for IE8 & IE9
        getStyle(rp, fontSizeStyleProperty) == '6pt' && getStyle(rt, fontSizeStyleProperty) == '6pt' ) {       // for IE6 & IE7

        cleanUp();
        return true;

    } else {
        cleanUp();
        return false;
    }

    function getStyle( element, styleProperty ) {
        var result;

        if ( window.getComputedStyle ) {     // for non-IE browsers
            result = document.defaultView.getComputedStyle(element,null).getPropertyValue(styleProperty);
        } else if ( element.currentStyle ) { // for IE
            result = element.currentStyle[styleProperty];
        }

        return result;
    }

    function cleanUp() {
        docElement.removeChild(ruby);
        // the removed child node still exists in memory, so ...
        ruby = null;
        rt = null;
        rp = null;
    }

});

Version data entries

144 entries across 144 versions & 7 rubygems

Version Path
jekyll-theme-pirati-7.7.1 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.7.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.6.2 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.6.1 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.6.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.5.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.4.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.3.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.2.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.1.1 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-7.0.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.9.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.8.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.7.2 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.7.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.6.2 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.6.1 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.6.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.5.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js
jekyll-theme-pirati-6.4.0 _sass/foundation-sites/vendor/modernizr/feature-detects/elem-ruby.js