Comparing version 4.0.6 to 4.0.7
@@ -53,17 +53,13 @@ 'use strict'; | ||
figure.addFigure(subfigure); | ||
subfigure.stateNeed = true; | ||
} | ||
if (node.options !== null) { | ||
figure.addOnUpdate((0, _sourceNode.sourceNode)(node.loc, [' ' + childrenName + '.forEach(function (view) {\n', ' view.update(__data__);\n', ' });'])); | ||
figure.addOnUpdate((0, _sourceNode.sourceNode)(node.loc, [' ' + childrenName + '.forEach(function (view) {\n', node.options === null ? '' : ' view.update(__data__);\n', ' view.update(view.__state__);\n', ' });'])); | ||
// Add to child(!) figure extra cache methods, | ||
// for saving data from loop options for render. | ||
[node.options.value, node.options.key].forEach(function (variable) { | ||
subfigure.thisRef = true; | ||
subfigure.prependOnUpdate((0, _sourceNode.sourceNode)([' if (_this.__cache__.' + variable + ') {\n', ' __data__.' + variable + ' = _this.__cache__.' + variable + ';\n', ' }'])); | ||
if (node.options && node.options.value) { | ||
subfigure.spot(node.options.value).onlyFromLoop = true; | ||
} | ||
// Cache all options data. | ||
subfigure.spot(variable).onlyFromLoop = true; | ||
subfigure.spot(variable).cache = true; | ||
}); | ||
if (node.options && node.options.key) { | ||
subfigure.spot(node.options.key).onlyFromLoop = true; | ||
} | ||
@@ -70,0 +66,0 @@ |
@@ -40,2 +40,3 @@ 'use strict'; | ||
this.thisRef = false; | ||
this.stateNeed = false; | ||
} | ||
@@ -65,2 +66,6 @@ | ||
if (this.stateNeed) { | ||
sn.add(' this.__state__ = {};\n'); | ||
} | ||
if (this.thisRef) { | ||
@@ -67,0 +72,0 @@ sn.add(' var _this = this;\n'); |
@@ -132,6 +132,6 @@ /** _ _ | ||
// If there is already some views, update there data with new. | ||
// If there is already some views, update there loop state. | ||
j = 0; | ||
for (i in map.items) { | ||
map.items[i].update(transform(array, keys, j, options)); | ||
map.items[i].__state__ = transform(array, keys, j, options); | ||
j++; | ||
@@ -156,4 +156,4 @@ } | ||
// Set view data (note what it must be after adding nodes to DOM). | ||
view.update(transform(array, keys, j, options)); | ||
// Set view state for later update in onUpdate. | ||
view.__state__ = transform(array, keys, j, options); | ||
} | ||
@@ -160,0 +160,0 @@ }; |
{ | ||
"name": "monkberry", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"description": "Monkberry is a JavaScript library for building web user interfaces", | ||
@@ -5,0 +5,0 @@ "bin": "bin/monkberry", |
216996