Skip to content

Commit

Permalink
Make renderedItemCount readOnly & add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Evans committed Dec 5, 2015
1 parent b589f70 commit e39d5ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/template/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@
*/
renderedItemCount: {
type: Number,
notify: true
notify: true,
readOnly: true
},

/**
Expand Down Expand Up @@ -450,7 +451,7 @@
// 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
Expand Down
17 changes: 17 additions & 0 deletions test/unit/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -3311,6 +3311,23 @@ <h4>x-repeat-chunked</h4>
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)');
Expand Down

0 comments on commit e39d5ba

Please sign in to comment.