Mercurial > urweb
diff lib/js/urweb.js @ 1039:8932f855fa85
grid0 working in IE
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 22 Nov 2009 15:30:15 -0500 |
parents | dcc6093e9575 |
children | ca5136105c45 |
line wrap: on
line diff
--- a/lib/js/urweb.js Sat Nov 21 15:48:08 2009 -0500 +++ b/lib/js/urweb.js Sun Nov 22 15:30:15 2009 -0500 @@ -116,7 +116,7 @@ function doExn(v) { if (v == null || v.uw_error == null) { - var s = (v == null ? "null" : v.toString()); + var s = (v == null ? "null" : v.message ? v.message : v.toString()); if (v != null && v.fileName && v.lineNumber) s += " (" + v.fileName + ":" + v.lineNumber + ")"; runHandlers("Fail", failHandlers, s); @@ -289,7 +289,9 @@ while (pos.lastChild && pos.lastChild.nodeType == 1) pos = pos.lastChild; - return pos.parentNode; + pos = pos.parentNode; + + return pos; } function parent() { @@ -315,6 +317,7 @@ scriptsCopy[i] = scripts[i]; for (var i = 0; i < len; ++i) { thisScript = scriptsCopy[i]; + try { eval(thisScript.text); } catch (v) { @@ -355,6 +358,7 @@ var next; for (var child = firstChild; child && child != x; child = next) { next = child.nextSibling; + killScript(child); if (child.getElementsByTagName) { var arr = child.getElementsByTagName("script"); @@ -367,7 +371,9 @@ } var cls = {v : null}; - var html = dynPrefix + flatten(cls, v); + var html = flatten(cls, v); + if (pnode != "table" && pnode != "tr") + html = dynPrefix + html; x.closures = cls.v; if (pnode == "table") { @@ -377,12 +383,22 @@ var table = x.parentNode; if (table) { - var arr = dummy.getElementsByTagName("tbody"); firstChild = null; var tbody; - if (arr.length > 0 && table != null) + + var arr = dummy.getElementsByTagName("tbody"); + + var tbody; + if (arr.length > 0 && arr[0].parentNode == dummy.firstChild) { tbody = arr[0]; - else + var next; + for (var node = dummy.firstChild.firstChild; node; node = next) { + next = node.nextSibling; + + if (node.tagName != "TBODY") + tbody.appendChild(node); + } + } else tbody = dummy.firstChild; var next; @@ -402,16 +418,16 @@ if (table) { var arr = dummy.getElementsByTagName("tr"); firstChild = null; - var tbody; + var tr; if (arr.length > 0 && table != null) - tbody = arr[0]; + tr = arr[0]; else - tbody = dummy.firstChild; + tr = dummy.firstChild; var next; firstChild = document.createElement("script"); table.insertBefore(firstChild, x); - for (var node = tbody.firstChild; node; node = next) { + for (var node = tr.firstChild; node; node = next) { next = node.nextSibling; table.insertBefore(node, x); } @@ -429,8 +445,9 @@ populate(x); } -function input(t, s, recreate) { +function input(t, s, recreate, type) { var x = document.createElement(t); + if (type) x.type = type; x.dead = false; x.signal = ss(s); x.sources = null; @@ -461,8 +478,7 @@ } function chk(s) { - var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }); - x.type = "checkbox"; + var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }, "checkbox"); x.checked = s.data; x.onchange = function() { sv(s, x.checked) };