diff --git a/lib/attr.js b/lib/attr.js index 825c794..5f88e17 100644 --- a/lib/attr.js +++ b/lib/attr.js @@ -38,8 +38,10 @@ live.attr = function(el, attributeName, compute) { // register that the handler changes the parent element canReflect.assignSymbols(liveUpdateAttr, { "can.getChangesDependencyRecord": function() { + var s = new Set(); + s.add(el); return { - valueDependencies: new Set( [ el ] ) + valueDependencies: s }; } }); diff --git a/lib/attrs.js b/lib/attrs.js index 951f267..8634456 100644 --- a/lib/attrs.js +++ b/lib/attrs.js @@ -65,8 +65,10 @@ live.attrs = function(el, compute, scope, options) { // register that the handler changes the parent element canReflect.assignSymbols(liveAttrsUpdate, { "can.getChangesDependencyRecord": function() { + var s = new Set(); + s.add(el); return { - valueDependencies: new Set( [ el ] ) + valueDependencies: s }; } }); @@ -97,7 +99,7 @@ live.attrs = function(el, compute, scope, options) { }; // unbind on element removal removalDisposal = domMutate.onNodeRemoval(el, function () { - if (!el.ownerDocument.contains(el)) { + if (!el.ownerDocument.documentElement.contains(el)) { teardownHandler(); } }); diff --git a/lib/core.js b/lib/core.js index a1c1f9c..d9f9bb6 100644 --- a/lib/core.js +++ b/lib/core.js @@ -65,7 +65,7 @@ var live = { } }; removalDisposal = domMutate.onNodeRemoval(el, function () { - if (!el.ownerDocument.contains(el)) { + if (!el.ownerDocument.documentElement.contains(el)) { teardown(); } }); diff --git a/lib/html.js b/lib/html.js index df7cfdc..8ee11a8 100644 --- a/lib/html.js +++ b/lib/html.js @@ -88,8 +88,10 @@ live.html = function(el, compute, parentNode, nodeListOrOptions) { // register that the handler changes the parent element canReflect.assignSymbols(liveHTMLUpdateHTML, { "can.getChangesDependencyRecord": function() { + var s = new Set(); + s.add(parentNode); return { - valueDependencies: new Set( [ parentNode ] ) + valueDependencies: s }; } }); diff --git a/lib/text.js b/lib/text.js index 3f6e2e9..46d3d18 100644 --- a/lib/text.js +++ b/lib/text.js @@ -43,8 +43,10 @@ live.text = function(el, compute, parentNode, nodeList) { // register that the handler changes the parent element canReflect.assignSymbols(liveTextUpdateTextNode, { "can.getChangesDependencyRecord": function() { + var s = new Set(); + s.add(parent); return { - valueDependencies: new Set( [ parent ] ) + valueDependencies: s }; } }); diff --git a/test/html-test.js b/test/html-test.js index 944c9ff..5e62bfe 100644 --- a/test/html-test.js +++ b/test/html-test.js @@ -92,12 +92,12 @@ test("html live binding handles objects with can.viewInsert symbol", 2, function div.appendChild(placeholder); var html = new Observation(function() { - return { - [canSymbol.for("can.viewInsert")]: function() { - assert.equal(arguments[0], options, "options were passed to symbol function"); - return document.createTextNode("Replaced text"); - } + var d = {}; + d[canSymbol.for("can.viewInsert")] = function() { + assert.equal(arguments[0], options, "options were passed to symbol function"); + return document.createTextNode("Replaced text"); }; + return d; }); live.html(placeholder, html, div, options);