dvtng / jss

JavaScript library for getting and setting CSS stylesheet rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in Chrome when using linked css file

amtivey opened this issue · comments

The following error is raised when linking css : Uncaught TypeError: Cannot read property 'length' of null

Test with the following code:

HTML

<html>
    <head>
        <title>rule test</title>
        <link rel="stylesheet" type="text/css" href="rule.css">
        <script type="text/javascript" src="jss.js"></script>
        <script>
            function test(rule) {
                var str = jss(rule).get();
                jss(rule, { color: 'blue' });
            }
        </script>
        <style>
            .rule-test-local { color: green; }
        </style>
    </head>
    <body>
        <div class="rule-test-link" onclick="test('.rule-test-link');">test linked css</div>
        <div class="rule-test-local" onclick="test('.rule-test-local');">test local css</div>
    </body>
</html>

CSS

.rule-test-link { color: red; }

I ran into this error aswell..

somehow

setTimeout(function() { jss(rule, { color: 'blue' }); }); 

fixed it for me

Since this is a known bug in chrome (https://code.google.com/p/chromium/issues/detail?id=49001) I am closing this issue.

Thanks for the suggestion Matt :)