summaryrefslogtreecommitdiff
path: root/lib/js
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/js
parent9e25c1ce13add31807463c913129c24643944e38 (diff)
'dynStyle' pseudo-attribute
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/urweb.js54
1 files changed, 38 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) {