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

Fetch stylesheets referenced by @import CSS rules instead of removing them #1091

Closed
westonruter opened this issue Apr 20, 2018 · 0 comments
Closed
Assignees
Milestone

Comments

@westonruter
Copy link
Member

When an @import rule is encountered in a stylesheet it is currently getting, it is currently getting deleted because it is not valid AMP:

https://github.com/Automattic/amp-wp/blob/31016b1cc92f8a2e3b75f57dac034b76efafda2e/includes/sanitizers/class-amp-style-sanitizer.php#L692-L697

However, there is no reason why we have to do this (note the @todo's related to this in the style sanitizer). We can instead rather fetch the contents of the @import'ed stylesheet as we're doing for external stylesheets loaded form link tags:

https://github.com/Automattic/amp-wp/blob/31016b1cc92f8a2e3b75f57dac034b76efafda2e/includes/sanitizers/class-amp-style-sanitizer.php#L440-L456

It is import-ant to support @import because it used to be the recommended way for child themes to include the style.css from the parent theme.

Note that we can also support loading @import'ed stylesheets from external domains (and not the filesystem) which will also be done for link tags in #1083.

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

No branches or pull requests

3 participants