diff options
-rw-r--r-- | lib/js/urweb.js | 7 | ||||
-rw-r--r-- | tests/doubleDyn.ur | 22 | ||||
-rw-r--r-- | tests/doubleDyn.urp | 4 |
3 files changed, 30 insertions, 3 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index ba73e744..adab5f43 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -643,9 +643,10 @@ function parent() { } function addNode(node) { - if (thisScript) - thisScript.parentNode.replaceChild(node, thisScript); - else + if (thisScript) { + if (thisScript.parentNode) + thisScript.parentNode.replaceChild(node, thisScript); + } else lastParent().appendChild(node); } diff --git a/tests/doubleDyn.ur b/tests/doubleDyn.ur new file mode 100644 index 00000000..97cf57d8 --- /dev/null +++ b/tests/doubleDyn.ur @@ -0,0 +1,22 @@ +style linktitle +style topic + +fun main () : transaction page = + text <- source "Lorem ipsum dolor sit amet"; + cls <- source linktitle; + return <xml> + <head> + <title>Dynamic CSS class test</title> + <link href="http://adam.chlipala.net/style.css" rel="stylesheet" type="text/css" media="all"/> + </head> + <body> + <dyn signal={t <- signal text; + return <xml><div dynClass={signal cls}>{[t]}</div></xml>}/> + <div dynClass={signal cls}> + <dyn signal={t <- signal text; return (txt t)}/> + </div> + <button value="Style1" onclick={set cls linktitle}/> + <button value="Style2" onclick={set cls topic}/> + <ctextbox source={text}/> + </body> + </xml> diff --git a/tests/doubleDyn.urp b/tests/doubleDyn.urp new file mode 100644 index 00000000..70522905 --- /dev/null +++ b/tests/doubleDyn.urp @@ -0,0 +1,4 @@ +allow url http://adam.chlipala.net/style.css +rewrite all DoubleDyn/* + +doubleDyn |