Make renderedItemCount readOnly & add tests.

This commit is contained in:
Arthur Evans 2015-12-04 17:14:56 -08:00
parent b589f70545
commit e39d5ba1fd
2 changed files with 20 additions and 2 deletions

View File

@ -199,7 +199,8 @@ Then the `observe` property should be configured as follows:
*/
renderedItemCount: {
type: Number,
notify: true
notify: true,
readOnly: true
},
/**
@ -450,7 +451,7 @@ Then the `observe` property should be configured as follows:
// the same item.
this._pool.length = 0;
// Set rendered item count
this.renderedItemCount = this._instances.length;
this._setRenderedItemCount(this._instances.length);
// Notify users
this.fire('dom-change');
// Check to see if we need to render more items

View File

@ -3311,6 +3311,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(repeater3.keyForElement(stamped1[4]), coll3.getKey(items3[2]));
});
test('renderedItemCount', function() {
var repeater1 = primitive.$.repeater1;
primitive.items = [ 'a', 'b', 'c', 'd', 'e' ];
repeater1.render();
assert.equal(repeater1.renderedItemCount, 5, 'renderedItemCount is incorrect');
repeater1.renderedItemCount = 0;
assert.equal(repeater1.renderedItemCount, 5, 'renderedItemCount is writable');
repeater1.filter = function(item) {
return (item != 'a' && item != 'e');
}
repeater1.render();
assert.equal(repeater1.renderedItemCount, 3, 'renderedItemCount incorrect after filter');
// reset repeater
repeater1.filter = undefined;
repeater1.render();
});
test('__hideTemplateChildren__', function() {
// Initially all showing
var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)');