summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-05-06 15:15:46 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-05-06 15:15:46 -0400
commit85341a176564ac3ce4e0a4ec4612262e2945660a (patch)
tree0b91d6fdd507e47f191183d49a4d5207ae515be7 /lib
parent9e25c1ce13add31807463c913129c24643944e38 (diff)
'dynStyle' pseudo-attribute
Diffstat (limited to 'lib')
-rw-r--r--lib/js/urweb.js54
-rw-r--r--lib/ur/basis.urs1
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