summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/js/urweb.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 638bb2b9..93822b17 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -189,6 +189,7 @@ function sc(v) {
}
function sv(s, v) {
s.data = v;
+
for (var ls = s.dyns; ls; ls = ls.next)
if (!ls.dead)
populate(ls.data);
@@ -262,6 +263,14 @@ function runScripts(node) {
// Dynamic tree entry points
+function killScript(scr) {
+ scr.dead = true;
+ for (var ls = scr.sources; ls; ls = ls.next)
+ ls.data.dyns = remove(scr, ls.data.dyns);
+ for (var ls = scr.closures; ls; ls = ls.next)
+ freeClosure(ls.data);
+}
+
function dyn(pnode, s) {
var x = document.createElement("script");
x.dead = false;
@@ -278,16 +287,11 @@ function dyn(pnode, s) {
var next;
for (var child = firstChild; child && child != x; child = next) {
next = child.nextSibling;
+ killScript(child);
if (child.getElementsByTagName) {
var arr = child.getElementsByTagName("script");
- for (var i = 0; i < arr.length; ++i) {
- var span = arr[i];
- span.dead = true;
- for (var ls = span.sources; ls; ls = ls.next)
- ls.data.dyns = remove(span, ls.data.dyns);
- for (var ls = span.closures; ls; ls = ls.next)
- freeClosure(ls.data);
- }
+ for (var i = 0; i < arr.length; ++i)
+ killScript(arr[i]);
}
if (child.parentNode)