Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(virtual-repeat): Prevent nested calls to virtualRepeatUpdate_ #5008

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/virtualRepeat/virtual-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,12 @@ function VirtualRepeatController($scope, $element, $attrs, $browser, $document,
/** @type {boolean} Whether this is the first time that items are rendered. */
this.isFirstRender = true;

/**
* @private {boolean} Whether the items in the list are already being updated. Used to prevent
* nested calls to virtualRepeatUpdate_.
*/
this.isVirtualRepeatUpdating_ = false;

/** @type {number} Most recently seen length of items. */
this.itemsLength = 0;

Expand Down Expand Up @@ -531,6 +537,11 @@ VirtualRepeatController.prototype.getItemSize = function() {
* @private
*/
VirtualRepeatController.prototype.virtualRepeatUpdate_ = function(items, oldItems) {
if (this.isVirtualRepeatUpdating_) {
return;
}

this.isVirtualRepeatUpdating_ = true;
var itemsLength = items ? items.length : 0;
var lengthChanged = false;

Expand Down Expand Up @@ -619,6 +630,7 @@ VirtualRepeatController.prototype.virtualRepeatUpdate_ = function(items, oldItem

this.startIndex = this.newStartIndex;
this.endIndex = this.newEndIndex;
this.isVirtualRepeatUpdating_ = false;
};


Expand Down