Skip to content

Conversation

georgefst
Copy link
Contributor

This is a proof-of-concept breaking version. I'm not quite sure what a good API would look like.

I have found this useful, particularly for specifying stylesheets.

@georgefst
Copy link
Contributor Author

An alternative, which I'm using for now, is to modify the head imperatively with jsaddle-dom. For example, these are essentially equivalent:

main = debugOr
    (Just $ encodeUtf8 $ TL.pack "<link rel='stylesheet' href='style.css'/>")
    port
    start
    app
main = debugOr
    Nothing -- passing `Nothing` here is the same as using the old version of `debugOr`
    port
    (insertStylesheet "style.css" >> start)
    app
  where
    insertStylesheet stylesheetUrl = do
        Just doc <- currentDocument
        Just headEl <- getHead doc
        linkEl <- unsafeCastTo HTMLLinkElement =<< createElement doc "link"
        setRel linkEl "stylesheet"
        setHref linkEl stylesheetUrl
        appendChild_ headEl linkEl

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant