Mercurial > urweb
changeset 1678:d05299e561c8
Fix bug with 'dynClass' immediately inside <dyn>
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 14 Jan 2012 11:24:17 -0500 |
parents | 3cfc79f92db7 |
children | 3636d0eeb39c |
files | lib/js/urweb.js tests/doubleDyn.ur tests/doubleDyn.urp |
diffstat | 3 files changed, 30 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/js/urweb.js Thu Jan 12 20:37:39 2012 -0500 +++ b/lib/js/urweb.js Sat Jan 14 11:24:17 2012 -0500 @@ -643,9 +643,10 @@ } 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); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/doubleDyn.ur Sat Jan 14 11:24:17 2012 -0500 @@ -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>