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

CORS stylesheets broken for relative resources #11

Open
rodneyrehm opened this issue Apr 30, 2014 · 7 comments
Open

CORS stylesheets broken for relative resources #11

rodneyrehm opened this issue Apr 30, 2014 · 7 comments
Labels

Comments

@rodneyrehm
Copy link
Owner

Simply downloading and injecting a CSS file into the DOM will break fonts and images referenced by a relative URL. This is because relative URLs within a <link>ed stylesheet are resolved against the URL of the CSS resource, but all resources in a <style> element are resolved against the URL of the document.

After downloading and before injecting the CSS, a processing step has to be introduced that scans the document for url("") and @import ""; occurrences and resolves relative paths against the stylesheet's URL.

Depending on URI.absoluteTo() for the heavy lifting may seem convenient, but adds way too much to the file size. The DOM URL interface is not available on iOS 7.

@miketramontano
Copy link

Hmm any progress made on this? Alternatively, is there a way to exclude certain domains from being procesed?

@rodneyrehm
Copy link
Owner Author

no progress has (as in no attempts to solve have) been made on this front so far. You're welcome to try :)

@miketramontano
Copy link

So this isn't going to be a good work around for all, but within importCrossOriginLinks, just inside the foreach over the document stylesheets, I've simply put a return to skip all of them. Does the trick for us since our cross origin css are only for fonts. At some point I'd like to throw an option in skipCrossOriginLinks and issue a pull request, but until then...

@paulftw
Copy link

paulftw commented Dec 21, 2014

+1 for adding an option to ignore certain stylesheets or URLs.
CSS files rarely use vh and vw so it's a bit of an overkill to process all of them.
I am assuming that parsing is done solely to replace all usages of viewport units - a wild guess since I don't yet understand how exactly the polyfill works.

@rodneyrehm
Copy link
Owner Author

v0.5.0 added an option to ignore certain style sheets <link rel="…" data-viewport-units-buggyfill="ignore">. Obviously this doesn't solve the core issue, but may help you circumvent the problems…

@exozed
Copy link

exozed commented Jan 29, 2015

If we copy the classes with vh and vw, with only vh, vw parts, on another style sheet and use buggyfill="ignore" on the main css. If we include the new file after the main css. Will this be a work around for relative images URLs and the loosing fonts?

@rodneyrehm
Copy link
Owner Author

that should work, yes

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

4 participants