diff options
author | 2012-01-14 11:24:17 -0500 | |
---|---|---|
committer | 2012-01-14 11:24:17 -0500 | |
commit | 792c8adae7f28d9dd80415c7130c2f17122550bf (patch) | |
tree | cb4f73a03b8d1d1eb97c8cab4742b4bed0f1e3e3 | |
parent | 82137590b9de8f10a6b0245cc881019baccd5340 (diff) |
Fix bug with 'dynClass' immediately inside <dyn>
-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 |