Skip to content
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

processStyleSheet function needs to use try/catch to avoid “SecurityError: The operation is insecure.” #20

Open
hellolindsay opened this issue Aug 18, 2014 · 0 comments
Labels

Comments

@hellolindsay
Copy link

When elementQuery tries to load an external style sheet, some browsers will throw an error: “SecurityError: The operation is insecure.” -- this comment explains how to fix it.

The error is thrown from line 151 in the unminified source:
if (styleSheet[cssRules] && styleSheet[cssRules].length > 0) {

Using try/catch, we can detect this error and return instead of letting the script fail. The simplest way to do this is to add the following line right above the if-statement (add this line to line 151, pushing the if-statment to line 152)

try { styleSheet[cssRules].length; } catch(err) { return; }

With this in place, the security error and it’s side-effects will disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants