diff --git a/src/lib/template/dom-repeat.html b/src/lib/template/dom-repeat.html index a211fb8421..86d8bd4b96 100644 --- a/src/lib/template/dom-repeat.html +++ b/src/lib/template/dom-repeat.html @@ -199,6 +199,10 @@ '_itemsChanged(items.*)' ], + created: function() { + this.rows = []; + }, + detached: function() { if (this.rows) { for (var i=0; i=0 ; i--) { var idx = removedRows[i]; - pool.push(this._detachRow(idx)); - rows.splice(idx, 1); - keys.splice(idx, 1); + // Removed idx may be undefined if item was previously filtered out + if (idx !== undefined) { + pool.push(this._detachRow(idx)); + rows.splice(idx, 1); + keys.splice(idx, 1); + } } } + // Add rows for added keys if (addedKeys.length) { // Filter added keys if (this._filterFn) { @@ -428,7 +451,7 @@ addedKeys.sort(function(a, b) { return this._sortFn(c.getItem(a), c.getItem(b)); }.bind(this)); - // Insert new rows using sort (from pool or newly created) + // Insertion-sort new rows into place (from pool or newly created) var start = 0; for (var i=0; iinDocumentRepeater var removed; - test('push', function() { + test('push', function(done) { unconfigured1.domUpdateHandlerCount = 0; unconfigured.push('items', {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[38].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39].itemaProp, 'new-1'); - assert.equal(stamped1[40].itemaProp, 'new-2'); - assert.equal(stamped1[41], undefined); - assert.equal(stamped2[38].itemcProp, 'prop-3-3-3'); - assert.equal(stamped2[38].indexa, 2); - assert.equal(stamped2[38].indexb, 2); - assert.equal(stamped2[38].indexc, 2); - assert.equal(stamped2[39].itemaProp, 'new-1'); - assert.equal(stamped2[40].itemaProp, 'new-2'); - assert.equal(stamped2[41], undefined); - assert.equal(unconfigured1.domUpdateHandlerCount, 1); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[38].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39].itemaProp, 'new-1'); + assert.equal(stamped1[40].itemaProp, 'new-2'); + assert.equal(stamped1[41], undefined); + assert.equal(stamped2[38].itemcProp, 'prop-3-3-3'); + assert.equal(stamped2[38].indexa, 2); + assert.equal(stamped2[38].indexb, 2); + assert.equal(stamped2[38].indexc, 2); + assert.equal(stamped2[39].itemaProp, 'new-1'); + assert.equal(stamped2[40].itemaProp, 'new-2'); + assert.equal(stamped2[41], undefined); + assert.equal(unconfigured1.domUpdateHandlerCount, 1); + done(); + }); }); - test('undo: push (using splice)', function() { + test('undo: push (using splice)', function(done) { unconfigured1.domUpdateHandlerCount = 0; unconfigured.splice('items', 3, 2); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[38].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); - assert.equal(stamped2[38].itemcProp, 'prop-3-3-3'); - assert.equal(stamped2[38].indexa, 2); - assert.equal(stamped2[38].indexb, 2); - assert.equal(stamped2[38].indexc, 2); - assert.equal(stamped2[39], undefined); - assert.equal(unconfigured1.domUpdateHandlerCount, 1); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[38].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + assert.equal(stamped2[38].itemcProp, 'prop-3-3-3'); + assert.equal(stamped2[38].indexa, 2); + assert.equal(stamped2[38].indexb, 2); + assert.equal(stamped2[38].indexc, 2); + assert.equal(stamped2[39], undefined); + assert.equal(unconfigured1.domUpdateHandlerCount, 1); + done(); + }); }); - test('pop', function() { + test('pop', function(done) { removed = unconfigured.pop('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[25].itemcProp, 'prop-2-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - assert.equal(stamped2[25].itemcProp, 'prop-2-3-3'); - assert.equal(stamped2[25].indexa, 1); - assert.equal(stamped2[25].indexb, 2); - assert.equal(stamped2[25].indexc, 2); - assert.equal(stamped2[26], undefined); - }); - - test('undo: pop (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[25].itemcProp, 'prop-2-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + assert.equal(stamped2[25].itemcProp, 'prop-2-3-3'); + assert.equal(stamped2[25].indexa, 1); + assert.equal(stamped2[25].indexb, 2); + assert.equal(stamped2[25].indexc, 2); + assert.equal(stamped2[26], undefined); + done(); + }); + }); + + test('undo: pop (using splice)', function(done) { unconfigured.splice('items', 2, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[38].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); - assert.equal(stamped2[38].itemcProp, 'prop-3-3-3'); - assert.equal(stamped2[38].indexa, 2); - assert.equal(stamped2[38].indexb, 2); - assert.equal(stamped2[38].indexc, 2); - assert.equal(stamped2[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[38].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + assert.equal(stamped2[38].itemcProp, 'prop-3-3-3'); + assert.equal(stamped2[38].indexa, 2); + assert.equal(stamped2[38].indexb, 2); + assert.equal(stamped2[38].indexc, 2); + assert.equal(stamped2[39], undefined); + done(); + }); }); - test('unshift', function() { + test('unshift', function(done) { unconfigured.unshift('items', {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'new-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'new-2'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itemaProp, 'prop-1'); - assert.equal(stamped1[2].indexa, 2); - assert.equal(stamped2[0].itemaProp, 'new-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped2[1].itemaProp, 'new-2'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped2[2].itemaProp, 'prop-1'); - assert.equal(stamped2[2].indexa, 2); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'new-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'new-2'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itemaProp, 'prop-1'); + assert.equal(stamped1[2].indexa, 2); + assert.equal(stamped2[0].itemaProp, 'new-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped2[1].itemaProp, 'new-2'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped2[2].itemaProp, 'prop-1'); + assert.equal(stamped2[2].indexa, 2); + done(); + }); }); - test('undo: unshift (using splice)', function() { + test('undo: unshift (using splice)', function(done) { unconfigured.splice('items', 0, 2); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + done(); + }); }); - test('shift', function() { + test('shift', function(done) { removed = unconfigured.shift('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-2'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-2-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-2-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-2'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-2-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-2-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-2'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-2-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-2-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-2'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-2-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-2-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + done(); + }); }); - test('undo: shift (using splice)', function() { + test('undo: shift (using splice)', function(done) { unconfigured.splice('items', 0, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + done(); + }); }); - test('splice - remove from middle', function() { + test('splice - remove from middle', function(done) { removed = unconfigured.splice('items', 1, 1)[0]; - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-3'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-3-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); - assert.equal(stamped2[13].itemaProp, 'prop-3'); - assert.equal(stamped2[13].indexa, 1); - assert.equal(stamped2[14].itembProp, 'prop-3-1'); - assert.equal(stamped2[14].indexa, 1); - assert.equal(stamped2[14].indexb, 0); - assert.equal(stamped2[15].itemcProp, 'prop-3-1-1'); - assert.equal(stamped2[15].indexa, 1); - assert.equal(stamped2[15].indexb, 0); - assert.equal(stamped2[15].indexc, 0); - }); - - test('undo: splice - remove from middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-3'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-3-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + assert.equal(stamped2[13].itemaProp, 'prop-3'); + assert.equal(stamped2[13].indexa, 1); + assert.equal(stamped2[14].itembProp, 'prop-3-1'); + assert.equal(stamped2[14].indexa, 1); + assert.equal(stamped2[14].indexb, 0); + assert.equal(stamped2[15].itemcProp, 'prop-3-1-1'); + assert.equal(stamped2[15].indexa, 1); + assert.equal(stamped2[15].indexb, 0); + assert.equal(stamped2[15].indexc, 0); + done(); + }); + }); + + test('undo: splice - remove from middle (using splice)', function(done) { unconfigured.splice('items', 1, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-2'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-2-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); - assert.equal(stamped2[13].itemaProp, 'prop-2'); - assert.equal(stamped2[13].indexa, 1); - assert.equal(stamped2[14].itembProp, 'prop-2-1'); - assert.equal(stamped2[14].indexa, 1); - assert.equal(stamped2[14].indexb, 0); - assert.equal(stamped2[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped2[15].indexa, 1); - assert.equal(stamped2[15].indexb, 0); - assert.equal(stamped2[15].indexc, 0); - }); - - test('splice - add to middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-2'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-2-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + assert.equal(stamped2[13].itemaProp, 'prop-2'); + assert.equal(stamped2[13].indexa, 1); + assert.equal(stamped2[14].itembProp, 'prop-2-1'); + assert.equal(stamped2[14].indexa, 1); + assert.equal(stamped2[14].indexb, 0); + assert.equal(stamped2[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped2[15].indexa, 1); + assert.equal(stamped2[15].indexb, 0); + assert.equal(stamped2[15].indexc, 0); + done(); + }); + }); + + test('splice - add to middle', function(done) { unconfigured.splice('items', 1, 0, {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'new-1'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itemaProp, 'new-2'); - assert.equal(stamped1[14].indexa, 2); - assert.equal(stamped1[15].itemaProp, 'prop-2'); - assert.equal(stamped1[15].indexa, 3); - assert.equal(stamped1[16].itembProp, 'prop-2-1'); - assert.equal(stamped1[16].indexa, 3); - assert.equal(stamped1[16].indexb, 0); - assert.equal(stamped1[17].itemcProp, 'prop-2-1-1'); - assert.equal(stamped1[17].indexa, 3); - assert.equal(stamped1[17].indexb, 0); - assert.equal(stamped1[17].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); - assert.equal(stamped2[13].itemaProp, 'new-1'); - assert.equal(stamped2[13].indexa, 1); - assert.equal(stamped2[14].itemaProp, 'new-2'); - assert.equal(stamped2[14].indexa, 2); - assert.equal(stamped2[15].itemaProp, 'prop-2'); - assert.equal(stamped2[15].indexa, 3); - assert.equal(stamped2[16].itembProp, 'prop-2-1'); - assert.equal(stamped2[16].indexa, 3); - assert.equal(stamped2[16].indexb, 0); - assert.equal(stamped2[17].itemcProp, 'prop-2-1-1'); - assert.equal(stamped2[17].indexa, 3); - assert.equal(stamped2[17].indexb, 0); - assert.equal(stamped2[17].indexc, 0); - }); - - test('undo: splice - add to middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'new-1'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itemaProp, 'new-2'); + assert.equal(stamped1[14].indexa, 2); + assert.equal(stamped1[15].itemaProp, 'prop-2'); + assert.equal(stamped1[15].indexa, 3); + assert.equal(stamped1[16].itembProp, 'prop-2-1'); + assert.equal(stamped1[16].indexa, 3); + assert.equal(stamped1[16].indexb, 0); + assert.equal(stamped1[17].itemcProp, 'prop-2-1-1'); + assert.equal(stamped1[17].indexa, 3); + assert.equal(stamped1[17].indexb, 0); + assert.equal(stamped1[17].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + assert.equal(stamped2[13].itemaProp, 'new-1'); + assert.equal(stamped2[13].indexa, 1); + assert.equal(stamped2[14].itemaProp, 'new-2'); + assert.equal(stamped2[14].indexa, 2); + assert.equal(stamped2[15].itemaProp, 'prop-2'); + assert.equal(stamped2[15].indexa, 3); + assert.equal(stamped2[16].itembProp, 'prop-2-1'); + assert.equal(stamped2[16].indexa, 3); + assert.equal(stamped2[16].indexb, 0); + assert.equal(stamped2[17].itemcProp, 'prop-2-1-1'); + assert.equal(stamped2[17].indexa, 3); + assert.equal(stamped2[17].indexb, 0); + assert.equal(stamped2[17].indexc, 0); + done(); + }); + }); + + test('undo: splice - add to middle (using splice)', function(done) { unconfigured.splice('items', 1, 2); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-2'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-2-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); - assert.equal(stamped2[13].itemaProp, 'prop-2'); - assert.equal(stamped2[13].indexa, 1); - assert.equal(stamped2[14].itembProp, 'prop-2-1'); - assert.equal(stamped2[14].indexa, 1); - assert.equal(stamped2[14].indexb, 0); - assert.equal(stamped2[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped2[15].indexa, 1); - assert.equal(stamped2[15].indexb, 0); - assert.equal(stamped2[15].indexc, 0); - }); - - test('splice - replace in middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-2'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-2-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + assert.equal(stamped2[13].itemaProp, 'prop-2'); + assert.equal(stamped2[13].indexa, 1); + assert.equal(stamped2[14].itembProp, 'prop-2-1'); + assert.equal(stamped2[14].indexa, 1); + assert.equal(stamped2[14].indexb, 0); + assert.equal(stamped2[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped2[15].indexa, 1); + assert.equal(stamped2[15].indexb, 0); + assert.equal(stamped2[15].indexc, 0); + done(); + }); + }); + + test('splice - replace in middle', function(done) { removed = unconfigured.splice('items', 1, 2, {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 2 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'new-1'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itemaProp, 'new-2'); - assert.equal(stamped1[14].indexa, 2); - assert.equal(stamped1[15], undefined); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); - assert.equal(stamped2[13].itemaProp, 'new-1'); - assert.equal(stamped2[13].indexa, 1); - assert.equal(stamped2[14].itemaProp, 'new-2'); - assert.equal(stamped2[14].indexa, 2); - assert.equal(stamped2[15], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 2 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'new-1'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itemaProp, 'new-2'); + assert.equal(stamped1[14].indexa, 2); + assert.equal(stamped1[15], undefined); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + assert.equal(stamped2[13].itemaProp, 'new-1'); + assert.equal(stamped2[13].indexa, 1); + assert.equal(stamped2[14].itemaProp, 'new-2'); + assert.equal(stamped2[14].indexa, 2); + assert.equal(stamped2[15], undefined); + done(); + }); }); - test('undo: splice - replace in middle (using splice)', function() { + test('undo: splice - replace in middle (using splice)', function(done) { unconfigured.splice('items', 1, 2, removed[0], removed[1]); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-2'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-2-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - assert.equal(stamped2[0].itemaProp, 'prop-1'); - assert.equal(stamped2[0].indexa, 0); - assert.equal(stamped2[1].itembProp, 'prop-1-1'); - assert.equal(stamped2[1].indexa, 0); - assert.equal(stamped2[1].indexb, 0); - assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped2[2].indexa, 0); - assert.equal(stamped2[2].indexb, 0); - assert.equal(stamped2[2].indexc, 0); - assert.equal(stamped2[13].itemaProp, 'prop-2'); - assert.equal(stamped2[13].indexa, 1); - assert.equal(stamped2[14].itembProp, 'prop-2-1'); - assert.equal(stamped2[14].indexa, 1); - assert.equal(stamped2[14].indexb, 0); - assert.equal(stamped2[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped2[15].indexa, 1); - assert.equal(stamped2[15].indexb, 0); - assert.equal(stamped2[15].indexc, 0); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + var stamped2 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped2.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-2'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-2-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + assert.equal(stamped2[0].itemaProp, 'prop-1'); + assert.equal(stamped2[0].indexa, 0); + assert.equal(stamped2[1].itembProp, 'prop-1-1'); + assert.equal(stamped2[1].indexa, 0); + assert.equal(stamped2[1].indexb, 0); + assert.equal(stamped2[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped2[2].indexa, 0); + assert.equal(stamped2[2].indexb, 0); + assert.equal(stamped2[2].indexc, 0); + assert.equal(stamped2[13].itemaProp, 'prop-2'); + assert.equal(stamped2[13].indexa, 1); + assert.equal(stamped2[14].itembProp, 'prop-2-1'); + assert.equal(stamped2[14].indexa, 1); + assert.equal(stamped2[14].indexb, 0); + assert.equal(stamped2[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped2[15].indexa, 1); + assert.equal(stamped2[15].indexb, 0); + assert.equal(stamped2[15].indexc, 0); + done(); + }); }); test('css scoping retained when re-ordering', function(done) { @@ -1305,419 +1305,419 @@

inDocumentRepeater

var removed; - test('push', function() { + test('push', function(done) { unconfigured1.$.repeater.filter = function(o) { return o.prop.indexOf('2') < 0; }; unconfigured.push('items', {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26].itemaProp, 'new-1'); - assert.equal(stamped1[26].indexa, 2); - assert.equal(stamped1[27], undefined); - }); - - test('undo: push (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26].itemaProp, 'new-1'); + assert.equal(stamped1[26].indexa, 2); + assert.equal(stamped1[27], undefined); + done(); + }); + }); + + test('undo: push (using splice)', function(done) { unconfigured.splice('items', 3, 2); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('pop', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('pop', function(done) { removed = unconfigured.pop('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[10].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[10].indexa, 0); - assert.equal(stamped1[10].indexb, 2); - assert.equal(stamped1[10].indexc, 0); - assert.equal(stamped1[11].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[11].indexa, 0); - assert.equal(stamped1[11].indexb, 2); - assert.equal(stamped1[11].indexc, 1); - assert.equal(stamped1[12].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[12].indexa, 0); - assert.equal(stamped1[12].indexb, 2); - assert.equal(stamped1[12].indexc, 2); - assert.equal(stamped1[13], undefined); - }); - - test('undo: pop (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[10].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[10].indexa, 0); + assert.equal(stamped1[10].indexb, 2); + assert.equal(stamped1[10].indexc, 0); + assert.equal(stamped1[11].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[11].indexa, 0); + assert.equal(stamped1[11].indexb, 2); + assert.equal(stamped1[11].indexc, 1); + assert.equal(stamped1[12].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[12].indexa, 0); + assert.equal(stamped1[12].indexb, 2); + assert.equal(stamped1[12].indexc, 2); + assert.equal(stamped1[13], undefined); + done(); + }); + }); + + test('undo: pop (using splice)', function(done) { unconfigured.splice('items', 2, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('unshift', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('unshift', function(done) { unconfigured.unshift('items', {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'new-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-1'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-1-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'new-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-1'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-1-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + done(); + }); }); - test('undo: unshift (using splice)', function() { + test('undo: unshift (using splice)', function(done) { unconfigured.splice('items', 0, 2); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('shift', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('shift', function(done) { removed = unconfigured.shift('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[10].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[10].indexa, 0); - assert.equal(stamped1[10].indexb, 2); - assert.equal(stamped1[10].indexc, 0); - assert.equal(stamped1[11].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[11].indexa, 0); - assert.equal(stamped1[11].indexb, 2); - assert.equal(stamped1[11].indexc, 1); - assert.equal(stamped1[12].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[12].indexa, 0); - assert.equal(stamped1[12].indexb, 2); - assert.equal(stamped1[12].indexc, 2); - assert.equal(stamped1[13], undefined); - }); - - test('undo: shift (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[10].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[10].indexa, 0); + assert.equal(stamped1[10].indexb, 2); + assert.equal(stamped1[10].indexc, 0); + assert.equal(stamped1[11].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[11].indexa, 0); + assert.equal(stamped1[11].indexb, 2); + assert.equal(stamped1[11].indexc, 1); + assert.equal(stamped1[12].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[12].indexa, 0); + assert.equal(stamped1[12].indexb, 2); + assert.equal(stamped1[12].indexc, 2); + assert.equal(stamped1[13], undefined); + done(); + }); + }); + + test('undo: shift (using splice)', function(done) { unconfigured.splice('items', 0, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('splice - remove from middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('splice - remove from middle', function(done) { removed = unconfigured.splice('items', 1, 1)[0]; - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('undo: splice - remove from middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('undo: splice - remove from middle (using splice)', function(done) { unconfigured.splice('items', 1, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('splice - add to middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('splice - add to middle', function(done) { unconfigured.splice('items', 1, 0, {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'new-1'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itemaProp, 'prop-3'); - assert.equal(stamped1[14].indexa, 2); - assert.equal(stamped1[15].itembProp, 'prop-3-1'); - assert.equal(stamped1[15].indexa, 2); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[16].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[16].indexa, 2); - assert.equal(stamped1[16].indexb, 0); - assert.equal(stamped1[16].indexc, 0); - }); - - test('undo: splice - add to middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'new-1'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itemaProp, 'prop-3'); + assert.equal(stamped1[14].indexa, 2); + assert.equal(stamped1[15].itembProp, 'prop-3-1'); + assert.equal(stamped1[15].indexa, 2); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[16].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[16].indexa, 2); + assert.equal(stamped1[16].indexb, 0); + assert.equal(stamped1[16].indexc, 0); + done(); + }); + }); + + test('undo: splice - add to middle (using splice)', function(done) { unconfigured.splice('items', 1, 2); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('splice - replace in middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('splice - replace in middle', function(done) { removed = unconfigured.splice('items', 1, 2, {prop: 'new-1'}, {prop: 'new-2'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'new-1'); - assert.equal(stamped1[14], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'new-1'); + assert.equal(stamped1[14], undefined); + done(); + }); }); - test('undo: splice - replace in middle (using splice)', function() { + test('undo: splice - replace in middle (using splice)', function(done) { unconfigured.splice('items', 1, 2, removed[0], removed[1]); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-3-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-3-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); }); }); @@ -1726,436 +1726,436 @@

inDocumentRepeater

var removed, a, m, z; - test('push', function() { + test('push', function(done) { unconfigured1.$.repeater.filter = null; unconfigured1.$.repeater.sort = function(a, b) { return b.prop == a.prop ? 0 : b.prop < a.prop ? -1 : 1; }; unconfigured.push('items', a={prop: 'a'}, m={prop: 'prop-1*'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-3'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-3-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[27].itemaProp, 'prop-1*'); - assert.equal(stamped1[27].indexa, 3); - assert.equal(stamped1[40].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[40].indexa, 4); - assert.equal(stamped1[40].indexb, 2); - assert.equal(stamped1[40].indexc, 2); - assert.equal(stamped1[41].itemaProp, 'a'); - assert.equal(stamped1[41].indexa, 5); - }); - - test('undo: push (using arrayDelete)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-3'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-3-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[27].itemaProp, 'prop-1*'); + assert.equal(stamped1[27].indexa, 3); + assert.equal(stamped1[40].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[40].indexa, 4); + assert.equal(stamped1[40].indexb, 2); + assert.equal(stamped1[40].indexc, 2); + assert.equal(stamped1[41].itemaProp, 'a'); + assert.equal(stamped1[41].indexa, 5); + done(); + }); + }); + + test('undo: push (using arrayDelete)', function(done) { unconfigured.arrayDelete('items', a); unconfigured.arrayDelete('items', m); unconfigured.arrayDelete('items', z); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + done(); + }); }); - test('pop', function() { + test('pop', function(done) { removed = unconfigured.pop('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); }); - test('undo: pop (using splice)', function() { + test('undo: pop (using splice)', function(done) { unconfigured.splice('items', 2, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + done(); + }); }); - test('unshift', function() { + test('unshift', function(done) { unconfigured.unshift('items', a={prop: 'a'}, m={prop: 'prop-1*'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-3'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-3-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[27].itemaProp, 'prop-1*'); - assert.equal(stamped1[27].indexa, 3); - assert.equal(stamped1[40].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[40].indexa, 4); - assert.equal(stamped1[40].indexb, 2); - assert.equal(stamped1[40].indexc, 2); - assert.equal(stamped1[41].itemaProp, 'a'); - assert.equal(stamped1[41].indexa, 5); - }); - - test('undo: unshift (using arrayDelete)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-3'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-3-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[27].itemaProp, 'prop-1*'); + assert.equal(stamped1[27].indexa, 3); + assert.equal(stamped1[40].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[40].indexa, 4); + assert.equal(stamped1[40].indexb, 2); + assert.equal(stamped1[40].indexc, 2); + assert.equal(stamped1[41].itemaProp, 'a'); + assert.equal(stamped1[41].indexa, 5); + done(); + }); + }); + + test('undo: unshift (using arrayDelete)', function(done) { unconfigured.arrayDelete('items', a); unconfigured.arrayDelete('items', m); unconfigured.arrayDelete('items', z); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + done(); + }); }); - test('shift', function() { + test('shift', function(done) { removed = unconfigured.shift('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-2-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-2-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-2-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('undo: shift (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-2-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-2-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-2-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('undo: shift (using splice)', function(done) { unconfigured.splice('items', 0, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + done(); + }); }); - test('splice - remove from middle', function() { + test('splice - remove from middle', function(done) { removed = unconfigured.splice('items', 1, 1)[0]; - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-1'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-1-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('undo: splice - remove from middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-1'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-1-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('undo: splice - remove from middle (using splice)', function(done) { unconfigured.splice('items', 1, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-2'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-2-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-2'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-2-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-2-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + done(); + }); }); - test('splice - add to middle', function() { + test('splice - add to middle', function(done) { unconfigured.splice('items', 1, 0, a={prop: 'a'}, m={prop: 'prop-1*'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-3'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-3-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[27].itemaProp, 'prop-1*'); - assert.equal(stamped1[27].indexa, 3); - assert.equal(stamped1[40].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[40].indexa, 4); - assert.equal(stamped1[40].indexb, 2); - assert.equal(stamped1[40].indexc, 2); - assert.equal(stamped1[41].itemaProp, 'a'); - assert.equal(stamped1[41].indexa, 5); - }); - - test('undo: splice - add to middle (using arrayDelete)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-3'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-3-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[27].itemaProp, 'prop-1*'); + assert.equal(stamped1[27].indexa, 3); + assert.equal(stamped1[40].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[40].indexa, 4); + assert.equal(stamped1[40].indexb, 2); + assert.equal(stamped1[40].indexc, 2); + assert.equal(stamped1[41].itemaProp, 'a'); + assert.equal(stamped1[41].indexa, 5); + done(); + }); + }); + + test('undo: splice - add to middle (using arrayDelete)', function(done) { unconfigured.arrayDelete('items', a); unconfigured.arrayDelete('items', m); unconfigured.arrayDelete('items', z); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + done(); + }); }); - test('splice - replace in middle', function() { + test('splice - replace in middle', function(done) { removed = unconfigured.splice('items', 1, 2, a={prop: 'a'}, m={prop: 'prop-1*'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-1*'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itemaProp, 'prop-1'); - assert.equal(stamped1[2].indexa, 2); - assert.equal(stamped1[3].itembProp, 'prop-1-1'); - assert.equal(stamped1[3].indexa, 2); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[4].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[4].indexa, 2); - assert.equal(stamped1[4].indexb, 0); - assert.equal(stamped1[4].indexc, 0); - assert.equal(stamped1[15].itemaProp, 'a'); - assert.equal(stamped1[15].indexa, 3); - assert.equal(stamped1[16], undefined); - }); - - test('undo: splice - replace in middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-1*'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itemaProp, 'prop-1'); + assert.equal(stamped1[2].indexa, 2); + assert.equal(stamped1[3].itembProp, 'prop-1-1'); + assert.equal(stamped1[3].indexa, 2); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[4].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[4].indexa, 2); + assert.equal(stamped1[4].indexb, 0); + assert.equal(stamped1[4].indexc, 0); + assert.equal(stamped1[15].itemaProp, 'a'); + assert.equal(stamped1[15].indexa, 3); + assert.equal(stamped1[16], undefined); + done(); + }); + }); + + test('undo: splice - replace in middle (using splice)', function(done) { unconfigured.arrayDelete('items', a); unconfigured.arrayDelete('items', m); unconfigured.arrayDelete('items', z); unconfigured.splice('items', 1, 2, removed[0], removed[1]); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[36].indexa, 2); - assert.equal(stamped1[36].indexb, 2); - assert.equal(stamped1[36].indexc, 0); - assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[37].indexa, 2); - assert.equal(stamped1[37].indexb, 2); - assert.equal(stamped1[37].indexc, 1); - assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[38].indexa, 2); - assert.equal(stamped1[38].indexb, 2); - assert.equal(stamped1[38].indexc, 2); - assert.equal(stamped1[39], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 3 + 3*3 + 3*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[36].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[36].indexa, 2); + assert.equal(stamped1[36].indexb, 2); + assert.equal(stamped1[36].indexc, 0); + assert.equal(stamped1[37].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[37].indexa, 2); + assert.equal(stamped1[37].indexb, 2); + assert.equal(stamped1[37].indexc, 1); + assert.equal(stamped1[38].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[38].indexa, 2); + assert.equal(stamped1[38].indexb, 2); + assert.equal(stamped1[38].indexc, 2); + assert.equal(stamped1[39], undefined); + done(); + }); }); }); @@ -2184,408 +2184,916 @@

inDocumentRepeater

CustomElements.takeRecords(); }); - test('push', function() { + test('push', function(done) { unconfigured.push('items', a={prop: 'a'}, m={prop: 'item*2'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-3'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-3-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[26].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[26].indexa, 2); - assert.equal(stamped1[26].indexb, 2); - assert.equal(stamped1[26].indexc, 2); - assert.equal(stamped1[27].itemaProp, 'a'); - assert.equal(stamped1[27].indexa, 3); - assert.equal(stamped1[28], undefined); - }); - - test('undo: push (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-3'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-3-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[26].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[26].indexa, 2); + assert.equal(stamped1[26].indexb, 2); + assert.equal(stamped1[26].indexc, 2); + assert.equal(stamped1[27].itemaProp, 'a'); + assert.equal(stamped1[27].indexa, 3); + assert.equal(stamped1[28], undefined); + done(); + }); + }); + + test('undo: push (using arrayDelete)', function(done) { unconfigured.arrayDelete('items', a); unconfigured.arrayDelete('items', m); unconfigured.arrayDelete('items', z); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('pop', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('pop', function(done) { removed = unconfigured.pop('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-1'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-1-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[12].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[12].indexa, 0); - assert.equal(stamped1[12].indexb, 2); - assert.equal(stamped1[12].indexc, 2); - assert.equal(stamped1[13], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-1'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-1-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[12].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[12].indexa, 0); + assert.equal(stamped1[12].indexb, 2); + assert.equal(stamped1[12].indexc, 2); + assert.equal(stamped1[13], undefined); + done(); + }); }); - test('undo: pop (using splice)', function() { + test('undo: pop (using splice)', function(done) { unconfigured.splice('items', 2, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('unshift', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('unshift', function(done) { unconfigured.unshift('items', a={prop: 'a'}, m={prop: 'item*2'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-3'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-3-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[26].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[26].indexa, 2); - assert.equal(stamped1[26].indexb, 2); - assert.equal(stamped1[26].indexc, 2); - assert.equal(stamped1[27].itemaProp, 'a'); - assert.equal(stamped1[27].indexa, 3); - assert.equal(stamped1[28], undefined); - }); - - test('undo: unshift (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-3'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-3-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[26].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[26].indexa, 2); + assert.equal(stamped1[26].indexb, 2); + assert.equal(stamped1[26].indexc, 2); + assert.equal(stamped1[27].itemaProp, 'a'); + assert.equal(stamped1[27].indexa, 3); + assert.equal(stamped1[28], undefined); + done(); + }); + }); + + test('undo: unshift (using splice)', function(done) { unconfigured.splice('items', 0, 3); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('shift', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('shift', function(done) { removed = unconfigured.shift('items'); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[12].itemcProp, 'prop-3-3-3'); - assert.equal(stamped1[12].indexa, 0); - assert.equal(stamped1[12].indexb, 2); - assert.equal(stamped1[12].indexc, 2); - assert.equal(stamped1[13], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[12].itemcProp, 'prop-3-3-3'); + assert.equal(stamped1[12].indexa, 0); + assert.equal(stamped1[12].indexb, 2); + assert.equal(stamped1[12].indexc, 2); + assert.equal(stamped1[13], undefined); + done(); + }); }); - test('undo: shift (using splice)', function() { + test('undo: shift (using splice)', function(done) { unconfigured.splice('items', 0, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('splice - remove from middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('splice - remove from middle', function(done) { removed = unconfigured.splice('items', 1, 1)[0]; - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[13].itemaProp, 'prop-1'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[14].itembProp, 'prop-1-1'); - assert.equal(stamped1[14].indexa, 1); - assert.equal(stamped1[14].indexb, 0); - assert.equal(stamped1[15].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[15].indexa, 1); - assert.equal(stamped1[15].indexb, 0); - assert.equal(stamped1[15].indexc, 0); - }); - - test('undo: splice - remove from middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[13].itemaProp, 'prop-1'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[14].itembProp, 'prop-1-1'); + assert.equal(stamped1[14].indexa, 1); + assert.equal(stamped1[14].indexb, 0); + assert.equal(stamped1[15].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[15].indexa, 1); + assert.equal(stamped1[15].indexb, 0); + assert.equal(stamped1[15].indexc, 0); + done(); + }); + }); + + test('undo: splice - remove from middle (using splice)', function(done) { unconfigured.splice('items', 1, 0, removed); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('splice - add to middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('splice - add to middle', function(done) { unconfigured.splice('items', 1, 0, a={prop: 'a'}, m={prop: 'item*2'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-3'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-3-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[26].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[26].indexa, 2); - assert.equal(stamped1[26].indexb, 2); - assert.equal(stamped1[26].indexc, 2); - assert.equal(stamped1[27].itemaProp, 'a'); - assert.equal(stamped1[27].indexa, 3); - assert.equal(stamped1[28], undefined); - }); - - test('undo: splice - add to middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-3'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-3-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[26].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[26].indexa, 2); + assert.equal(stamped1[26].indexb, 2); + assert.equal(stamped1[26].indexc, 2); + assert.equal(stamped1[27].itemaProp, 'a'); + assert.equal(stamped1[27].indexa, 3); + assert.equal(stamped1[28], undefined); + done(); + }); + }); + + test('undo: splice - add to middle (using splice)', function(done) { unconfigured.splice('items', 1, 3); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); - }); - - test('splice - replace in middle', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); + }); + + test('splice - replace in middle', function(done) { removed = unconfigured.splice('items', 1, 2, a={prop: 'a'}, m={prop: 'item*2'}, z={prop: 'z'}); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'z'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itemaProp, 'prop-1'); - assert.equal(stamped1[1].indexa, 1); - assert.equal(stamped1[2].itembProp, 'prop-1-1'); - assert.equal(stamped1[2].indexa, 1); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[3].itemcProp, 'prop-1-1-1'); - assert.equal(stamped1[3].indexa, 1); - assert.equal(stamped1[3].indexb, 0); - assert.equal(stamped1[3].indexc, 0); - assert.equal(stamped1[13].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[13].indexa, 1); - assert.equal(stamped1[13].indexb, 2); - assert.equal(stamped1[13].indexc, 2); - assert.equal(stamped1[14].itemaProp, 'a'); - assert.equal(stamped1[14].indexa, 2); - assert.equal(stamped1[15], undefined); - }); - - test('undo: splice - replace in middle (using splice)', function() { + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 1 + 1*3 + 1*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'z'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itemaProp, 'prop-1'); + assert.equal(stamped1[1].indexa, 1); + assert.equal(stamped1[2].itembProp, 'prop-1-1'); + assert.equal(stamped1[2].indexa, 1); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[3].itemcProp, 'prop-1-1-1'); + assert.equal(stamped1[3].indexa, 1); + assert.equal(stamped1[3].indexb, 0); + assert.equal(stamped1[3].indexc, 0); + assert.equal(stamped1[13].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[13].indexa, 1); + assert.equal(stamped1[13].indexb, 2); + assert.equal(stamped1[13].indexc, 2); + assert.equal(stamped1[14].itemaProp, 'a'); + assert.equal(stamped1[14].indexa, 2); + assert.equal(stamped1[15], undefined); + done(); + }); + }); + + test('undo: splice - replace in middle (using splice)', function(done) { unconfigured.splice('items', 1, 3, removed[0], removed[1]); - unconfigured1.$.repeater.render(); - CustomElements.takeRecords(); - CustomElements.takeRecords(); - var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); - assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); - assert.equal(stamped1[0].itemaProp, 'prop-3'); - assert.equal(stamped1[0].indexa, 0); - assert.equal(stamped1[1].itembProp, 'prop-3-1'); - assert.equal(stamped1[1].indexa, 0); - assert.equal(stamped1[1].indexb, 0); - assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); - assert.equal(stamped1[2].indexa, 0); - assert.equal(stamped1[2].indexb, 0); - assert.equal(stamped1[2].indexc, 0); - assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); - assert.equal(stamped1[23].indexa, 1); - assert.equal(stamped1[23].indexb, 2); - assert.equal(stamped1[23].indexc, 0); - assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); - assert.equal(stamped1[24].indexa, 1); - assert.equal(stamped1[24].indexb, 2); - assert.equal(stamped1[24].indexc, 1); - assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); - assert.equal(stamped1[25].indexa, 1); - assert.equal(stamped1[25].indexb, 2); - assert.equal(stamped1[25].indexc, 2); - assert.equal(stamped1[26], undefined); + setTimeout(function() { + var stamped1 = Polymer.dom(unconfigured1.root).querySelectorAll('*:not(template)'); + assert.equal(stamped1.length, 2 + 2*3 + 2*3*3, 'total stamped count incorrect'); + assert.equal(stamped1[0].itemaProp, 'prop-3'); + assert.equal(stamped1[0].indexa, 0); + assert.equal(stamped1[1].itembProp, 'prop-3-1'); + assert.equal(stamped1[1].indexa, 0); + assert.equal(stamped1[1].indexb, 0); + assert.equal(stamped1[2].itemcProp, 'prop-3-1-1'); + assert.equal(stamped1[2].indexa, 0); + assert.equal(stamped1[2].indexb, 0); + assert.equal(stamped1[2].indexc, 0); + assert.equal(stamped1[23].itemcProp, 'prop-1-3-1'); + assert.equal(stamped1[23].indexa, 1); + assert.equal(stamped1[23].indexb, 2); + assert.equal(stamped1[23].indexc, 0); + assert.equal(stamped1[24].itemcProp, 'prop-1-3-2'); + assert.equal(stamped1[24].indexa, 1); + assert.equal(stamped1[24].indexb, 2); + assert.equal(stamped1[24].indexc, 1); + assert.equal(stamped1[25].itemcProp, 'prop-1-3-3'); + assert.equal(stamped1[25].indexa, 1); + assert.equal(stamped1[25].indexb, 2); + assert.equal(stamped1[25].indexc, 2); + assert.equal(stamped1[26], undefined); + done(); + }); }); }); + suite('multiple mutations in same turn', function() { + + test('array sort, no filter: unshift+pop', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + primitive.unshift('items', 'new1'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'a'); + assert.equal(stamped1[2].itemaProp, 'b'); + assert.equal(stamped1[3].itemaProp, 'c'); + assert.equal(stamped1[4].itemaProp, 'd'); + primitive.unshift('items', 'new2'); + primitive.pop('items'); + primitive.unshift('items', 'new3'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new3'); + assert.equal(stamped1[1].itemaProp, 'new2'); + assert.equal(stamped1[2].itemaProp, 'new1'); + assert.equal(stamped1[3].itemaProp, 'a'); + assert.equal(stamped1[4].itemaProp, 'b'); + primitive.shift('items'); + primitive.push('items', 'c'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new2'); + assert.equal(stamped1[1].itemaProp, 'new1'); + assert.equal(stamped1[2].itemaProp, 'a'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'c'); + primitive.shift('items'); + primitive.push('items', 'd'); + primitive.shift('items'); + primitive.push('items', 'e'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + }); + }); + }); + + test('array sort, no filter: insertions', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + primitive.splice('items', 1, 0, 'new2', 'new3'); + primitive.splice('items', 0, 0, 'new1'); + primitive.splice('items', 8, 0, 'new5'); + primitive.splice('items', 5, 0, 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'a'); + assert.equal(stamped1[2].itemaProp, 'new2'); + assert.equal(stamped1[3].itemaProp, 'new3'); + assert.equal(stamped1[4].itemaProp, 'b'); + assert.equal(stamped1[5].itemaProp, 'new4'); + assert.equal(stamped1[6].itemaProp, 'c'); + assert.equal(stamped1[7].itemaProp, 'd'); + assert.equal(stamped1[8].itemaProp, 'e'); + assert.equal(stamped1[9].itemaProp, 'new5'); + primitive.arrayDelete('items', 'new5'); + primitive.arrayDelete('items', 'new3'); + primitive.arrayDelete('items', 'new1'); + primitive.arrayDelete('items', 'new2'); + primitive.arrayDelete('items', 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + }); + + test('array sort, no filter: insert & remove', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + primitive.splice('items', 1, 0, 'new1', 'new2', 'new3'); + primitive.splice('items', 3, 1); + primitive.splice('items', 4, 0, 'new4', 'new5', 'new6'); + primitive.splice('items', 4, 2); + primitive.splice('items', 4, 1); + primitive.splice('items', 1, 2); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + + test('array sort, filtered: unshift+pop', function(done) { + primitive.$.repeater1.filter = function(s) { + return s.indexOf('new2') < 0; + }; + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + primitive.unshift('items', 'new1'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'a'); + assert.equal(stamped1[2].itemaProp, 'b'); + assert.equal(stamped1[3].itemaProp, 'c'); + assert.equal(stamped1[4].itemaProp, 'd'); + primitive.unshift('items', 'new2'); + primitive.pop('items'); + primitive.unshift('items', 'new3'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new3'); + assert.equal(stamped1[1].itemaProp, 'new1'); + assert.equal(stamped1[2].itemaProp, 'a'); + assert.equal(stamped1[3].itemaProp, 'b'); + primitive.shift('items'); + primitive.push('items', 'c'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'a'); + assert.equal(stamped1[2].itemaProp, 'b'); + assert.equal(stamped1[3].itemaProp, 'c'); + primitive.shift('items'); + primitive.push('items', 'd'); + primitive.shift('items'); + primitive.push('items', 'e'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + }); + }); + }); + + test('array sort, filtered: insertions', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + primitive.splice('items', 1, 0, 'new2', 'new3'); + primitive.splice('items', 0, 0, 'new1'); + primitive.splice('items', 8, 0, 'new5'); + primitive.splice('items', 5, 0, 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'a'); + assert.equal(stamped1[2].itemaProp, 'new3'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'new4'); + assert.equal(stamped1[5].itemaProp, 'c'); + assert.equal(stamped1[6].itemaProp, 'd'); + assert.equal(stamped1[7].itemaProp, 'e'); + assert.equal(stamped1[8].itemaProp, 'new5'); + primitive.arrayDelete('items', 'new5'); + primitive.arrayDelete('items', 'new3'); + primitive.arrayDelete('items', 'new1'); + primitive.arrayDelete('items', 'new2'); + primitive.arrayDelete('items', 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + }); + + test('array sort, filtered: insert & remove', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + primitive.splice('items', 1, 0, 'new1', 'new2', 'new3'); + primitive.splice('items', 3, 1); + primitive.splice('items', 4, 0, 'new4', 'new5', 'new6'); + primitive.splice('items', 4, 2); + primitive.splice('items', 4, 1); + primitive.splice('items', 1, 2); + primitive.$.repeater1.filter = null; + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + + test('view sort, no filter: unshift+pop', function(done) { + primitive.$.repeater1.sort = function(a, b) { + return b.localeCompare(a); + }; + setTimeout(function() { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.unshift('items', 'new1'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.unshift('items', 'new2'); + primitive.pop('items'); + primitive.unshift('items', 'new3'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new3'); + assert.equal(stamped1[1].itemaProp, 'new2'); + assert.equal(stamped1[2].itemaProp, 'new1'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.shift('items'); + primitive.push('items', 'c'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new2'); + assert.equal(stamped1[1].itemaProp, 'new1'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.shift('items'); + primitive.push('items', 'd'); + primitive.shift('items'); + primitive.push('items', 'e'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + done(); + }); + }); + }); + }); + }); + }); + + test('view sort, no filter: insertions', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.splice('items', 1, 0, 'new2', 'new3'); + primitive.splice('items', 0, 0, 'new1'); + primitive.splice('items', 8, 0, 'new5'); + primitive.splice('items', 5, 0, 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new5'); + assert.equal(stamped1[1].itemaProp, 'new4'); + assert.equal(stamped1[2].itemaProp, 'new3'); + assert.equal(stamped1[3].itemaProp, 'new2'); + assert.equal(stamped1[4].itemaProp, 'new1'); + assert.equal(stamped1[5].itemaProp, 'e'); + assert.equal(stamped1[6].itemaProp, 'd'); + assert.equal(stamped1[7].itemaProp, 'c'); + assert.equal(stamped1[8].itemaProp, 'b'); + assert.equal(stamped1[9].itemaProp, 'a'); + primitive.arrayDelete('items', 'new5'); + primitive.arrayDelete('items', 'new3'); + primitive.arrayDelete('items', 'new1'); + primitive.arrayDelete('items', 'new2'); + primitive.arrayDelete('items', 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + done(); + }); + }); + }); + + test('view sort, no filter: insert & remove', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.splice('items', 1, 0, 'new1', 'new2', 'new3'); + primitive.splice('items', 3, 1); + primitive.splice('items', 4, 0, 'new4', 'new5', 'new6'); + primitive.splice('items', 4, 2); + primitive.splice('items', 4, 1); + primitive.splice('items', 1, 2); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + done(); + }); + }); + + test('view sort, filtered: unshift+pop', function(done) { + primitive.$.repeater1.filter = function(s) { + return s.indexOf('new2') < 0; + }; + setTimeout(function() { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.unshift('items', 'new1'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.unshift('items', 'new2'); + primitive.pop('items'); + primitive.unshift('items', 'new3'); + primitive.pop('items'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new3'); + assert.equal(stamped1[1].itemaProp, 'new1'); + assert.equal(stamped1[2].itemaProp, 'b'); + assert.equal(stamped1[3].itemaProp, 'a'); + primitive.shift('items'); + primitive.push('items', 'c'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new1'); + assert.equal(stamped1[1].itemaProp, 'c'); + assert.equal(stamped1[2].itemaProp, 'b'); + assert.equal(stamped1[3].itemaProp, 'a'); + primitive.shift('items'); + primitive.push('items', 'd'); + primitive.shift('items'); + primitive.push('items', 'e'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + done(); + }); + }); + }); + }); + }); + }); + + test('view sort, no filter: insertions', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.splice('items', 1, 0, 'new2', 'new3'); + primitive.splice('items', 0, 0, 'new1'); + primitive.splice('items', 8, 0, 'new5'); + primitive.splice('items', 5, 0, 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'new5'); + assert.equal(stamped1[1].itemaProp, 'new4'); + assert.equal(stamped1[2].itemaProp, 'new3'); + assert.equal(stamped1[3].itemaProp, 'new1'); + assert.equal(stamped1[4].itemaProp, 'e'); + assert.equal(stamped1[5].itemaProp, 'd'); + assert.equal(stamped1[6].itemaProp, 'c'); + assert.equal(stamped1[7].itemaProp, 'b'); + assert.equal(stamped1[8].itemaProp, 'a'); + primitive.arrayDelete('items', 'new5'); + primitive.arrayDelete('items', 'new3'); + primitive.arrayDelete('items', 'new1'); + primitive.arrayDelete('items', 'new2'); + primitive.arrayDelete('items', 'new4'); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + done(); + }); + }); + }); + + test('view sort, no filter: insert & remove', function(done) { + // repeater 1 + var stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.splice('items', 1, 0, 'new1', 'new2', 'new3'); + primitive.splice('items', 3, 1); + primitive.splice('items', 4, 0, 'new4', 'new5', 'new6'); + primitive.splice('items', 4, 2); + primitive.splice('items', 4, 1); + primitive.splice('items', 1, 2); + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'e'); + assert.equal(stamped1[1].itemaProp, 'd'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'b'); + assert.equal(stamped1[4].itemaProp, 'a'); + primitive.$.repeater1.filter = null; + primitive.$.repeater1.sort = null; + setTimeout(function() { + stamped1 = Polymer.dom(primitive.$.container1).querySelectorAll('*:not(template)'); + assert.equal(stamped1[0].itemaProp, 'a'); + assert.equal(stamped1[1].itemaProp, 'b'); + assert.equal(stamped1[2].itemaProp, 'c'); + assert.equal(stamped1[3].itemaProp, 'd'); + assert.equal(stamped1[4].itemaProp, 'e'); + done(); + }); + }); + }); + + }); + + + suite('item changing on instance', function() { test('primitive values - initial stamping', function() {