diff --git a/src/array/ArrayBinding.js b/src/array/ArrayBinding.js index 80b29e4..86d2a2a 100644 --- a/src/array/ArrayBinding.js +++ b/src/array/ArrayBinding.js @@ -22,7 +22,6 @@ define([ function ArrayBinding(model, propertyType) { var properties = []; - var elements = []; (function createProperties() { diff --git a/src/array/ArrayElement.js b/src/array/ArrayElement.js index 3532305..bf60c64 100644 --- a/src/array/ArrayElement.js +++ b/src/array/ArrayElement.js @@ -3,7 +3,6 @@ define(["array/ArrayItemElement"], function(ArrayItemElement) { function ArrayElement(domElement, initialLength) { var element = domElement.get(); - var child; (function checkElementHasOnlyOneChild() { diff --git a/src/array/method/Pop_.js b/src/array/method/Pop_.js index 1e383c2..8491d22 100644 --- a/src/array/method/Pop_.js +++ b/src/array/method/Pop_.js @@ -7,7 +7,6 @@ define([], function() { model.pop = function() { var popped = originalPop.apply(this, arguments); - var property = properties.pop(); if (property) { diff --git a/src/array/method/Shift.js b/src/array/method/Shift.js index 9658404..7d865b3 100644 --- a/src/array/method/Shift.js +++ b/src/array/method/Shift.js @@ -7,7 +7,6 @@ define([], function() { model.shift = function() { var shifted = originalShift.apply(this, arguments); - var property = properties.shift(); if (property) { diff --git a/src/callback/CallbackBinder.js b/src/callback/CallbackBinder.js index bd24a93..e12eacb 100644 --- a/src/callback/CallbackBinder.js +++ b/src/callback/CallbackBinder.js @@ -23,7 +23,7 @@ define([ var elements = getMatchingElements(scope, name); - bindElements(elements, scope, model); + bindElements(elements, model); addElements(elements); }; @@ -62,14 +62,13 @@ define([ } } - function bindElements(elements, scope, model) { + function bindElements(elements, model) { for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (scope.hasInScope(element) && - !boundElements.contains(element)) { + if (!boundElements.contains(element)) { binding.setUpElement(model, element.get()); new Registry().requestRegistrations(); diff --git a/src/element/DOMElement.js b/src/element/DOMElement.js index bf05f2b..5976c0a 100644 --- a/src/element/DOMElement.js +++ b/src/element/DOMElement.js @@ -45,9 +45,19 @@ define([ if (isNaN(key)) { var elements = element.querySelectorAll("[data-bind=" + key + "]"); - var elementsArray = [].slice.call(elements); + var elementsArray = []; - return elementsArray.map(function(item) { return new DOMElement(item); }); + for (var i = 0; i < elements.length; i++) { + + var newElement = new DOMElement(elements[i]); + + if (this.hasInScope(newElement)) { + + elementsArray.push(newElement); + } + } + + return elementsArray; } else { diff --git a/src/element/NullDOMElement.js b/src/element/NullDOMElement.js index ec2e4f1..e9e6e89 100644 --- a/src/element/NullDOMElement.js +++ b/src/element/NullDOMElement.js @@ -19,7 +19,7 @@ define([], function() { this.getMatchingElements = function() { - return [new NullDOMElement()]; + return []; }; this.hasDataBindAttribute = function() { diff --git a/src/object/ObjectBinder.js b/src/object/ObjectBinder.js index 9074c2d..454f3d8 100644 --- a/src/object/ObjectBinder.js +++ b/src/object/ObjectBinder.js @@ -34,19 +34,16 @@ define([ var element = elements[i]; - if (scope.hasInScope(element)) { + if (boundElements.contains(element)) { - if (boundElements.contains(element)) { - - binding.updateElement(model, element, model && model[name]); - } - else { + binding.updateElement(model, element, model && model[name]); + } + else { - binding.setUpElement(model, element, model && model[name]); - new Registry().requestRegistrations(); - binding.updateElement(model, element, model && model[name]); - binding.createCallback(scope, element); - } + binding.setUpElement(model, element, model && model[name]); + new Registry().requestRegistrations(); + binding.updateElement(model, element, model && model[name]); + binding.createCallback(scope, element); } } } diff --git a/src/object/ViewModel.js b/src/object/ViewModel.js index ad79c6a..72e7d1e 100644 --- a/src/object/ViewModel.js +++ b/src/object/ViewModel.js @@ -16,9 +16,7 @@ define([ function ViewModel(model) { var boundElements = new ElementSet(); - var transientProperties = {}; - var permanentProperties = {}; new Serialisable(model); @@ -46,20 +44,17 @@ define([ function bindElement(element, scope, name) { - if (scope.hasInScope(element)) { - - if (!boundElements.contains(element)) { + if (!boundElements.contains(element)) { - createRebinder(element, scope, name); - element.callBindingCallback(model); - } - - unbindOldProperties(); - createPermanentProperties(); - createTransientProperties(); - bindProperties(element); - boundElements.add(element); + createRebinder(element, scope, name); + element.callBindingCallback(model); } + + unbindOldProperties(); + createPermanentProperties(); + createTransientProperties(); + bindProperties(element); + boundElements.add(element); } function createRebinder(element, scope, name) { diff --git a/src/property/PermanentProperty.js b/src/property/PermanentProperty.js index 5e4b380..15c0296 100644 --- a/src/property/PermanentProperty.js +++ b/src/property/PermanentProperty.js @@ -3,7 +3,6 @@ define([], function() { function PermanentProperty(property, propertyType) { var objectBinding; - var propertyInjected = false; if (typeof(property) == "object" && !isBinding(property)) {