lib/packages/core-classes.js
function() {

		var data_source = this._foreach_scope.getValue(),
			new_uids = data_source.getUIDs(),
			new_uid_to_index_map = data_source.getUIDToIndexMap(),
			count = data_source.getCount(),
			i = 0,
			uid,
			template,
			removed_templates = [],
			child_properties,
			current_templates = [];

		for (; i < this._current_count; i++) {

			uid = this._current_uids[i];

			if (!(uid in new_uid_to_index_map)) {

				removed_templates.push(this._current_hash[uid]);
				delete this._current_hash[uid];

			}

		}

		for (i = 0; i < count; i++) {

			uid = new_uids[i];

			child_properties = {
				foreach_index: i,
				foreach_name: data_source.getNameAt(new_uid_to_index_map[uid])
			};
			child_properties[this._as] = data_source.getValueAt(new_uid_to_index_map[uid]);

			if (uid in this._current_hash) {

				template = this._current_hash[uid];
				template.batchSetProperties(child_properties);

			} else {

				template = new Lava.system.Template(this._config.template, this._widget, this, child_properties);
				this._current_hash[uid] = template;

			}

			current_templates.push(template);

		}

		removed_templates.length && this._removeTemplates(removed_templates);

		this._current_count = count;
		this._current_uids = new_uids;
		this._current_templates = current_templates;
		this._requires_refresh_children = false;

	}
function() {

		var data_source = this._foreach_scope.getValue(),
			new_uids = data_source.getUIDs(),
			new_uid_to_index_map = data_source.getUIDToIndexMap(),
			count = data_source.getCount(),
			i = 0,
			uid,
			template,
			removed_templates = [],
			child_properties,
			current_templates = [];

		for (; i < this._current_count; i++) {

			uid = this._current_uids[i];

			if (!(uid in new_uid_to_index_map)) {

				removed_templates.push(this._current_hash[uid]);
				delete this._current_hash[uid];

			}

		}

		for (i = 0; i < count; i++) {

			uid = new_uids[i];

			child_properties = {
				foreach_index: i,
				foreach_name: data_source.getNameAt(new_uid_to_index_map[uid])
			};
			child_properties[this._as] = data_source.getValueAt(new_uid_to_index_map[uid]);

			if (uid in this._current_hash) {

				template = this._current_hash[uid];
				template.batchSetProperties(child_properties);

			} else {

				template = new Lava.system.Template(this._config.template, this._widget, this, child_properties);
				this._current_hash[uid] = template;

			}

			current_templates.push(template);

		}

		removed_templates.length && this._removeTemplates(removed_templates);

		this._current_count = count;
		this._current_uids = new_uids;
		this._current_templates = current_templates;
		this._requires_refresh_children = false;

	}
function ( ) { var data_source = this . _foreach_scope . getValue ( ) , new_uids = data_source . getUIDs ( ) , new_uid_to_index_map = data_source . getUIDToIndexMap ( ) , count = data_source . getCount ( ) , i = 0 , uid , template , removed_templates = [ ] , child_properties , current_templates = [ ] ; for ( ; i < this . _current_count ; i ++ ) { uid = this . _current_uids [ i ] ; if ( ! ( uid in new_uid_to_index_map ) ) { removed_templates . push ( this . _current_hash [ uid ] ) ; delete this . _current_hash [ uid ] ; } } for ( i = 0 ; i < count ; i ++ ) { uid = new_uids [ i ] ; child_properties = { foreach_index : i , foreach_name : data_source . getNameAt ( new_uid_to_index_map [ uid ] ) } ; child_properties [ this . _as ] = data_source . getValueAt ( new_uid_to_index_map [ uid ] ) ; if ( uid in this . _current_hash ) { template = this . _current_hash [ uid ] ; template . batchSetProperties ( child_properties ) ; } else { template = new Lava . system . Template ( this . _config . template , this . _widget , this , child_properties ) ; this . _current_hash [ uid ] = template ; } current_templates . push ( template ) ; } removed_templates . length && this . _removeTemplates ( removed_templates ) ; this . _current_count = count ; this . _current_uids = new_uids ; this . _current_templates = current_templates ; this . _requires_refresh_children = false ; }
Remove old templates, create new
Remove old templates create new