-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
From what I found on JS behavior this isn't expected behavior, usually inserting <script>
does execute it.
I searched over Props_script
for something like "enableExecution" but found nothing. I don't suppose this is expected to happen.
Steps to reproduce
- Create new project with
spago init
- Create
index.html
as<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="styles.css"> </head> <body> <div id="root"></div> <script src="index.js"></script> </body> </html>
- Put this code to
src/Main.purs
module Main where import Prelude import Data.Maybe (Maybe(..)) import Effect (Effect) import Effect.Exception (throw) import React.Basic.DOM as R import React.Basic.DOM.Client (createRoot, renderRoot) import React.Basic.Hooks (Component, component) import Web.DOM.NonElementParentNode (getElementById) import Web.HTML (window) import Web.HTML.HTMLDocument (toNonElementParentNode) import Web.HTML.Window (document) main :: Effect Unit main = do doc <- document =<< window root <- getElementById "root" $ toNonElementParentNode doc case root of Nothing -> throw "Could not find root." Just container -> do reactRoot <- createRoot container app <- myComponent renderRoot reactRoot (app {}) myComponent :: Component {} myComponent = component "Test" \_ -> React.do pure $ R.script {children: [R.text "alert(1)"]}
- Install deps as
spago install console effect exceptions maybe prelude react-basic react-basic-dom react-basic-hooks web-dom web-html
- Build it with
spago bundle-app
- Open
index.html
in a browser
Expected
An alert should pop up
Actual
No popups appear
Metadata
Metadata
Assignees
Labels
No labels