diff options
author | Adam Chlipala <adam@chlipala.net> | 2012-05-06 15:15:46 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2012-05-06 15:15:46 -0400 |
commit | 7bb3cb12e6a013204e794db821069d8b9e0ecc58 (patch) | |
tree | 0b91d6fdd507e47f191183d49a4d5207ae515be7 /lib | |
parent | d6d65ece7537f856f01fdc978a2560107cacc375 (diff) |
'dynStyle' pseudo-attribute
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 54 | ||||
-rw-r--r-- | lib/ur/basis.urs | 1 |
2 files changed, 39 insertions, 16 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 74badd36..4f6a5f22 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -944,7 +944,7 @@ function tbx(s) { return x; } -function dynClass(html, s) { +function dynClass(html, s_class, s_style) { var htmlCls = {v : null}; html = flatten(htmlCls, html); htmlCls = htmlCls.v; @@ -956,23 +956,45 @@ function dynClass(html, s) { dummy.removeChild(html); addNode(html); - var x = document.createElement("script"); - x.dead = false; - x.signal = s; - x.sources = null; - x.closures = htmlCls; - - x.recreate = function(v) { - for (var ls = x.closures; ls != htmlCls; ls = ls.next) - freeClosure(ls.data); + if (s_class) { + var x = document.createElement("script"); + x.dead = false; + x.signal = s_class; + x.sources = null; + x.closures = htmlCls; + + x.recreate = function(v) { + for (var ls = x.closures; ls != htmlCls; ls = ls.next) + freeClosure(ls.data); + + var cls = {v : null}; + html.className = flatten(cls, v); + x.closures = concat(cls.v, htmlCls); + } - var cls = {v : null}; - html.className = flatten(cls, v); - x.closures = concat(cls.v, htmlCls); - }; + addNode(x); + populate(x); + } - addNode(x); - populate(x); + if (s_style) { + var x = document.createElement("script"); + x.dead = false; + x.signal = s_style; + x.sources = null; + x.closures = htmlCls; + + x.recreate = function(v) { + for (var ls = x.closures; ls != htmlCls; ls = ls.next) + freeClosure(ls.data); + + var cls = {v : null}; + html.style.cssText = flatten(cls, v); + x.closures = concat(cls.v, htmlCls); + } + + addNode(x); + populate(x); + } } function addOnChange(x, f) { diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 1c9de4b9..760cc4d2 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -662,6 +662,7 @@ val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type} css_class -> option (signal css_class) -> css_style + -> option (signal css_style) -> $attrsGiven -> tag (attrsGiven ++ attrsAbsent) ctxOuter ctxInner useOuter bindOuter |