Skip to content

Support <style> tags as well as <link> for theme stylesΒ #93

@fastpok

Description

@fastpok

I wanted to use <style ...> tags instead of <link rel="stylesheet" ...> but this didn't work.

Here is my example:

<style media="(prefers-color-scheme: light)">body {color: red;}</style>
<style media="(prefers-color-scheme: dark)">body {color: blue;}</style>

I think this code is responsible for that.

// We need to support `media="(prefers-color-scheme: dark)"` (with space)
// and `media="(prefers-color-scheme:dark)"` (without space)
this._darkCSS = doc.querySelectorAll(
`${LINK_REL_STYLESHEET}[${MEDIA}*=${PREFERS_COLOR_SCHEME}][${MEDIA}*="${DARK}"]`,
);
this._lightCSS = doc.querySelectorAll(
`${LINK_REL_STYLESHEET}[${MEDIA}*=${PREFERS_COLOR_SCHEME}][${MEDIA}*="${LIGHT}"]`,
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions