Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/VirtualDom/Styled.elm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module VirtualDom.Styled exposing
, unstyledNode
)

import Css
import Css.Preprocess as Preprocess exposing (Style)
import Css.Preprocess.Resolve as Resolve
import Css.Structure as Structure
Expand Down Expand Up @@ -479,13 +480,18 @@ toKeyedStyleNode maybeNonce allStyles keyedChildNodes =

toStyleNode : Maybe Nonce -> Dict CssTemplate Classname -> VirtualDom.Node msg
toStyleNode maybeNonce styles =
-- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
let
styleWrapperClass =
"elm-css-style-wrapper"
in
-- wrap the style node in a span to prevent `Dark Reader` from blowin up the dom.
VirtualDom.node "span"
[ VirtualDom.attribute "style" "display: none;"
, VirtualDom.attribute "class" "elm-css-style-wrapper"
]
[ VirtualDom.attribute "class" styleWrapperClass ]
[ -- this <style> node will be the first child of the requested one
toDeclaration styles
styles
|> toDeclaration
-- add css to hide the wrapper span
|> styleToDeclaration (getCssTemplate [ Css.display Css.none ]) styleWrapperClass
|> VirtualDom.text
|> List.singleton
|> VirtualDom.node "style"
Expand Down