CurrentStyle in IE is null

I am trying to clear the current style of an element:

function cssIsLoaded(c) {
    if (window.getComputedStyle) {
        return window.getComputedStyle(c, null).display === "none";
    }
    else if (c.currentStyle) {

    }

    return true;
}

(function() {
    var cssload = document.createElement("div");
    cssload.className = "_css_loaded";
    checkLoaded();

    function checkLoaded() {
        if (!cssIsLoaded(cssload)) setTimeout(function() {
            checkLoaded();
        }, 20);
        else blalbalblbalbalablbal();
    }
})();

IE is not part of the second condition, c.currentStyleit is null ... why is this?

+3
source share
1 answer

An element does not get its property currentStylefilled before it was added to the document, which makes sense: until the element has been added to the document, the browser cannot know what existing style rules will apply to it.

+7
source

Source: https://habr.com/ru/post/1774058/


All Articles