diff options
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r-- | lib/js/urweb.js | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 2e350378..c3cab50a 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -1009,8 +1009,6 @@ function active(s) { if (suspendScripts) return; - var span = document.createElement("span"); - addNode(span); var ms = maySuspend; maySuspend = false; try { @@ -1020,7 +1018,11 @@ function active(s) { throw e; } maySuspend = ms; - setInnerHTML(span, html); + if (html != "") { + var span = document.createElement("span"); + addNode(span); + setInnerHTML(span, html); + } } function input(x, s, recreate, type, name) { @@ -1111,7 +1113,7 @@ function tbx(s) { return x; } -function dynClass(html, s_class, s_style) { +function dynClass(pnode, html, s_class, s_style) { if (suspendScripts) return; @@ -1119,7 +1121,7 @@ function dynClass(html, s_class, s_style) { html = flatten(htmlCls, html); htmlCls = htmlCls.v; - var dummy = document.createElement("body"); + var dummy = document.createElement(pnode); suspendScripts = true; dummy.innerHTML = html; suspendScripts = false; @@ -1150,23 +1152,23 @@ function dynClass(html, s_class, s_style) { 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; - - x.recreate = function(v) { - for (var ls = x.closures; ls != htmlCls2; ls = ls.next) + var y = document.createElement("script"); + y.dead = false; + y.signal = s_style; + y.sources = null; + y.closures = htmlCls2; + + 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); } } @@ -1940,6 +1942,19 @@ function bless(s) { } +// Attribute name blessing + +function blessData(s) { + for (var i = 0; i < s.length; ++i) { + var c = s[i]; + if (!isAlnum(c) && c != '-' && c != '_') + er("Disallowed character in data-* attribute name"); + } + + return s; +} + + // CSS validation function atom(s) { |