-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error - rules[i].selectorText is undefined #2
Comments
The usage looks correct. Are you able to provide a bit more info? What browser? Is it a |
Actually I think I may have found the cause. Certain @rules in the CSS create rules without selectorText, so I added an additional check to make sure it first exists. I've updated |
Cheers for the speedy response! A parameter or an operation is not supported by the underlying object" code: "15 I'm pretty sure i haven't done anything out of the ordinary.
I know i can easily just set the colours again in the JS file, but pulling them from the CSS file is much more streamlined - especially when the design colours still need a lot of tweaking :) The other reason is becuase i have:
Which i want to light up when the child Debug info: Using |
Thanks for the detailed information. There could be two problems here: First, it could be that the external stylesheet has not finished loading by the time your code executes. This could be the case if you're using jQuery's Second, a known issue is with trying to access stylesheets loaded from a different domain (or protocol). However, this should give a "security error" rather than the one you reported. I hope that using |
Hmm now this is interesting! HOWEVER... I encased the required code within
And i am now getting the following error in firebug: Security error" code: "1000 [Break On This Error] rules = sheet.cssRules || sheet.rules; Google Chrome developer tools throws this error: Uncaught TypeError: Cannot read property 'length' of null I am testing this on a local web environment (MAMP PRO). |
It looks like you cannot read CSS stylesheets loaded locally. I find it odd that this restriction applies to files served from a web server running locally as well - are the CSS files being served by apache on localhost? |
Yeah, the CSS files are being served by Apache on localhost. |
I had the same problem reading a local stylesheet. My JavaScript code for traversing the stylesheet returned undefined and quit when it encountered a rule starting with an ampersand: @Keyframes. I don't know any way around this problem. |
The answer to the problem is to put all CSS rules that begin with @ at the end of each CSS style sheet. Probably put a zombie rule before the start of the @rules. That way, when you're looking for a real rule you'll find it before you reach .zombie and the @rules. .rule1 {whatever} |
Just tried this JSS script out to try and make some jquery hover functions a little bit more streamlined with the CSS styles already set.
I seem to be getting the following error:
rules[i].selectorText is undefined
At first i thought it was because i was referencing an element that didn't exist, but that's now not the case.
var linksHoverColour = jss('#links li a:hover').get()['color'];
Am i using the code correctly?
The text was updated successfully, but these errors were encountered: