# HG changeset patch # User Adam Chlipala # Date 1399221224 14400 # Node ID 2b2d07946e6554bba8f7c875713ef1a21f69d676 # Parent cfd604842006cb6fc90131ada44a5bcf9a7e38f1 Fix dynClass for non- contexts diff -r cfd604842006 -r 2b2d07946e65 lib/js/urweb.js --- a/lib/js/urweb.js Sat May 03 07:59:45 2014 -0400 +++ b/lib/js/urweb.js Sun May 04 12:33:44 2014 -0400 @@ -1113,7 +1113,7 @@ return x; } -function dynClass(html, s_class, s_style) { +function dynClass(pnode, html, s_class, s_style) { if (suspendScripts) return; @@ -1121,7 +1121,7 @@ html = flatten(htmlCls, html); htmlCls = htmlCls.v; - var dummy = document.createElement("body"); + var dummy = document.createElement(pnode); suspendScripts = true; dummy.innerHTML = html; suspendScripts = false; @@ -1152,23 +1152,23 @@ if (s_style) { var htmlCls2 = s_class ? null : htmlCls; - var x = document.createElement("script"); - x.dead = false; - x.signal = s_style; - x.sources = null; - x.closures = htmlCls2; + var y = document.createElement("script"); + y.dead = false; + y.signal = s_style; + y.sources = null; + y.closures = htmlCls2; - x.recreate = function(v) { - for (var ls = x.closures; ls != htmlCls2; ls = ls.next) + y.recreate = function(v) { + for (var ls = y.closures; ls != htmlCls2; ls = ls.next) freeClosure(ls.data); var cls = {v : null}; html.style.cssText = flatten(cls, v); - x.closures = concat(cls.v, htmlCls2); + y.closures = concat(cls.v, htmlCls2); } - html.appendChild(x); - populate(x); + html.appendChild(y); + populate(y); } } diff -r cfd604842006 -r 2b2d07946e65 src/monoize.sml --- a/src/monoize.sml Sat May 03 07:59:45 2014 -0400 +++ b/src/monoize.sml Sun May 04 12:33:44 2014 -0400 @@ -3230,7 +3230,7 @@ (L.ECApp ( (L.ECApp ( (L.EFfi ("Basis", "tag"), - _), (L.CRecord (_, attrsGiven), _)), _), _), _), _), _), _), _), _), _), _), _), _), _), _), _), + _), (L.CRecord (_, attrsGiven), _)), _), _), _), ctxOuter), _), _), _), _), _), _), _), _), _), _), _), class), _), dynClass), _), style), _), @@ -3581,6 +3581,19 @@ (L'.EPrim (Prim.String ")"), loc)), loc)), loc) end + fun inTag tag' = case ctxOuter of + (L.CRecord (_, ctx), _) => + List.exists (fn ((L.CName tag'', _), _) => tag'' = tag' + | _ => false) ctx + | _ => false + + fun pnode () = if inTag "Tr" then + "tr" + else if inTag "Table" then + "table" + else + "span" + val baseAll as (base, fm) = case tag of "body" => let @@ -3603,24 +3616,12 @@ | "dyn" => let - fun inTag tag = case targs of - (L.CRecord (_, ctx), _) :: _ => - List.exists (fn ((L.CName tag', _), _) => tag' = tag - | _ => false) ctx - | _ => false - - val tag = if inTag "Tr" then - "tr" - else if inTag "Table" then - "table" - else - "span" in case attrs of [("Signal", e, _)] => ((L'.EStrcat ((L'.EPrim (Prim.String ("")), loc)), loc)), loc), fm) @@ -3834,7 +3835,9 @@ L'.ENone _ => (case #1 dynStyle of L'.ENone _ => baseAll - | L'.ESome (_, ds) => (strcat [str "