can-stache-bindings
Advanced tools
Comparing version 4.2.2 to 4.2.3
@@ -32,2 +32,3 @@ // # can-stache-bindings.js | ||
var makeCompute = require("can-view-scope/make-compute-like"); | ||
var ViewNodeList = require("can-view-nodelist"); | ||
@@ -238,3 +239,5 @@ var canEvent = require("can-attribute-observable/event"); | ||
semaphore = {}, | ||
teardown; | ||
teardown, | ||
attributeDisposal, | ||
removedDisposal; | ||
@@ -294,10 +297,13 @@ // Setup binding | ||
}; | ||
// Listen for changes | ||
teardown = dataBinding.onTeardown; | ||
var attributeDisposal = domMutate.onNodeAttributeChange(el, attributeListener); | ||
var removedDisposal = domMutate.onNodeRemoval(el, function () { | ||
var tearItAllDown = function(){ | ||
if (el.ownerDocument.contains(el)) { | ||
return; | ||
} | ||
teardown(); | ||
if(teardown) { | ||
teardown(); | ||
teardown = undefined; | ||
} | ||
if (removedDisposal) { | ||
@@ -311,3 +317,13 @@ removedDisposal(); | ||
} | ||
}); | ||
}; | ||
if(attrData.nodeList) { | ||
ViewNodeList.register([],tearItAllDown, attrData.nodeList, false); | ||
} | ||
// Listen for changes | ||
teardown = dataBinding.onTeardown; | ||
attributeDisposal = domMutate.onNodeAttributeChange(el, attributeListener); | ||
removedDisposal = domMutate.onNodeRemoval(el, tearItAllDown); | ||
}, | ||
@@ -652,2 +668,5 @@ // ### bindings.behaviors.event | ||
function updateParent(newVal) { | ||
if(!bindingInfo.active) { | ||
return; | ||
} | ||
if (!bindingsSemaphore[attrName]) { | ||
@@ -721,2 +740,5 @@ if (parentObservable && parentObservable[getValueSymbol]) { | ||
var updateChild = function updateChild(newValue) { | ||
if(!bindingInfo.active) { | ||
return; | ||
} | ||
// Save the viewModel property name so it is not updated multiple times. | ||
@@ -914,2 +936,4 @@ // We listen for when the batch has ended, and all observation updates have ended. | ||
} | ||
// hack in the active check (#278) | ||
bindingInfo.active = true; | ||
@@ -983,2 +1007,3 @@ // assign some bindingData props to the bindingInfo | ||
var onTeardown = function() { | ||
bindingInfo.active = false; | ||
unbindUpdate(parentObservable, updateChild); | ||
@@ -985,0 +1010,0 @@ unbindUpdate(childObservable, updateParent); |
{ | ||
"name": "can-stache-bindings", | ||
"version": "4.2.2", | ||
"version": "4.2.3", | ||
"description": "Default binding syntaxes for can-stache", | ||
@@ -5,0 +5,0 @@ "homepage": "https://canjs.com/doc/can-stache-bindings.html", |
@@ -375,2 +375,16 @@ var QUnit = require('steal-qunit'); | ||
QUnit.test("parent stache is able to teardown child bindings (#278)", function(){ | ||
var map = new SimpleMap({value: "VALUE"}); | ||
var template = stache("<div>{{#if value}}<span><input value:bind='value'/></span>{{/if}}</div>"); | ||
var frag = template(map), | ||
input = frag.firstChild.getElementsByTagName("input")[0]; | ||
QUnit.equal(input.value, "VALUE", "value set initially"); | ||
map.set("value",""); | ||
QUnit.equal(input.value, "VALUE", "value should not have been updated"); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170399
3706