-
Notifications
You must be signed in to change notification settings - Fork 151
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
Fails silently on CSS loaded from subdomain #6
Comments
Until now I didn't even realise that SOP had any effect on CSSOM. Does that happen in all browsers? Without having fully read the spec (whichever version…), this feels like a browser bug. |
Derp. There goes that plan. I think I'm just going to take the output of your script while I'm testing on localhost and save it off as an ios specific rule set. Not very flexible, but unless you can think of another work around, I think this is what I have to do. |
Have you tried seting CORS headers for those resources (if only to test)? A static output won't do you any good, as you don't know the viewport's dimensions ahead of time. What we could discuss, though, is a way to identify and extract the offending rules. You'd likely want to do that statically with rework. Simply filter out anything that doesn't use viewport units and save the result to another file. That one could then be loaded - on iOS only - from the "proper" origin. (honestly, I'd try the CORS thing first…) |
Yeah, I was going to try and get tricky with some media queries and all the permutations of ios devices. (Fortunately, there aren't many variations) I tried just adding the access control headers, but I haven't run a full xhr implementation. I'll run some tests and let you know what I find. |
OK, Here's how I got it to work...
|
I just verified that only setting the CORS headers won't "magically" make the CSSOM grant access to the content. bummer. So we'll have to check for |
I think we can fold your check in with the chuck I posted above to reach global stylesheet nirvana. |
Also, I don't think you need to replace the link. If you just add the |
A restyle is happening, no way around that. if that triggers a layout and subsequently a paint is up to the browser. You'd want to remove the I hope to get to adding this tomorrow evening. |
Thanks for your help on this one. This bug was driving me crazy for about two full days. Since we don't use the cdn on localhost or staging, it was only showing up in production. Everybody's least favorite type of bug. I was happy that I finally tracked down the problem, and then immediately bummed that there wasn't a simply solution. :) |
Thanks for the find. This would've bitten me sooner or later. |
No problem. |
Due to the Cross Origin Policy, documents.stylesheets[x].cssRules returns null for stylesheets loaded from a different domain, including subdomains. This means the script has nothing relevant to process, and simply doesn't work. This is especially frustrating for people like myself who serve static content like CSS, JS, and images from a CDN.
I've been looking around and haven't found a fix yet. Possibly CORS, but I'm still testing things out. Do you have any ideas?
The text was updated successfully, but these errors were encountered: