From 0b38f30883241b7dc45f8e2b8ff1a9c52a8b1536 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Wed, 24 Aug 2016 12:14:14 -0400 Subject: Plug a reactive-DOM memory leak (thanks to Saulo Araujo for spotting the problem and proposing a slightly different fix) --- lib/js/urweb.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/js/urweb.js') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 95fd6756..222a8322 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -1100,12 +1100,18 @@ function active(s) { function input(x, s, recreate, type, name) { if (name) x.name = name; if (type) x.type = type; - x.dead = false; - x.signal = ss(s); - x.sources = null; - x.recreate = recreate(x); addNode(x); - populate(x); + + var sc = document.createElement("script"); + sc.dead = false; + sc.signal = ss(s); + sc.sources = null; + sc.recreate = recreate(x); + + if (x.parentNode) + x.parentNode.insertBefore(sc, x); + + populate(sc); return x; } -- cgit v1.2.3