Skip to content

CORS stylesheets broken for relative resources #11

@rodneyrehm

Description

@rodneyrehm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions