Fixes #3065: Add dom-repeat.renderedItemCount property

This commit is contained in:
Arthur Evans 2015-11-20 14:59:59 -08:00
parent 4d45842a40
commit b589f70545
2 changed files with 15 additions and 0 deletions

View File

@ -191,6 +191,17 @@ Then the `observe` property should be configured as follows:
*/
delay: Number,
/**
* Count of currently rendered items after `filter` (if any) has been applied.
* If "chunking mode" is enabled, `renderedItemCount` is updated each time a
* set of template instances is rendered.
*
*/
renderedItemCount: {
type: Number,
notify: true
},
/**
* Defines an initial count of template instances to render after setting
* the `items` array, before the next paint, and puts the `dom-repeat`
@ -438,6 +449,8 @@ Then the `observe` property should be configured as follows:
// `item` may not be sufficient if the pooled instance happens to be
// the same item.
this._pool.length = 0;
// Set rendered item count
this.renderedItemCount = this._instances.length;
// Notify users
this.fire('dom-change');
// Check to see if we need to render more items

View File

@ -115,6 +115,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('basic rendering, downward item binding', function() {
var stamped = Polymer.dom(configured.root).querySelectorAll('*:not(template)');
assert.equal(stamped.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect');
assert.equal(configured.$.repeater.renderedItemCount, 3, 'rendered item count incorrect');
assert.equal(stamped[0].itemaProp, 'prop-1');
assert.equal(stamped[0].computeda, 'prop-1+itemForComputedA');
assert.equal(stamped[0].indexa, 0);
@ -282,6 +283,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
CustomElements.takeRecords();
var stamped = Polymer.dom(configured.root).querySelectorAll('*:not(template)');
assert.equal(stamped.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect');
assert.equal(configured.$.repeater.renderedItemCount, 2, 'rendered item count incorrect');
assert.equal(stamped[0].itemaProp, 'prop-1');
assert.equal(stamped[0].indexa, 0);
assert.equal(stamped[13].itemaProp, 'prop-3');