Skip to content
This repository was archived by the owner on Sep 28, 2019. It is now read-only.

Commit efd12a3

Browse files
bedeoverendTimvdLippe
authored andcommitted
Fix timing issue with multiple stamps (#42)
1 parent 68b4187 commit efd12a3

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

iron-lazy-pages-behavior.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@
8888
}
8989
this._setLoading(true);
9090
event.detail.item._loadAndShow(function(cb) {
91+
var protectedCb = this.selectedItem === event.detail.item ? cb : function(){};
9192
this._setLoading(false);
9293
if (this._lastSelected) {
9394
this._callback = cb;
94-
this._hide(this._lastSelected, cb)
95+
this._hide(this._lastSelected, protectedCb)
9596
} else {
96-
cb();
97+
protectedCb();
9798
}
9899
if (this.selectedAttribute) {
99100
event.detail.item._toggleAttribute(this.selectedAttribute, true);

test/basic-test.html

+15
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@
295295
pages.select('foo');
296296
assertStamped('Foo');
297297
});
298+
299+
test('does not stamp late load if no longer selected', function() {
300+
var firstSuccessCallback;
301+
302+
fakeImport(0, 'foo.html');
303+
pages.select('foo');
304+
firstSuccessCallback = callbackSuccess;
305+
306+
fakeImport(1, 'bar.html');
307+
pages.select('bar');
308+
callbackSuccess();
309+
firstSuccessCallback();
310+
311+
assertStamped('Bar');
312+
});
298313
}
299314
});
300315
</script>

0 commit comments

Comments
 (0)