Calculate cursor stops after change list rendered
Polymer.dom.flush is expensive operation, we can use afterNextRender, so we don't interrupt polymer rendering. It saves around 100 ms on dashboard. Change-Id: I5137397d5893e933f602f335c597136581e33ad2
This commit is contained in:
@@ -366,9 +366,10 @@
|
|||||||
|
|
||||||
_sectionsChanged() {
|
_sectionsChanged() {
|
||||||
// Flush DOM operations so that the list item elements will be loaded.
|
// Flush DOM operations so that the list item elements will be loaded.
|
||||||
Polymer.dom.flush();
|
Polymer.RenderStatus.afterNextRender(this, () => {
|
||||||
this.$.cursor.stops = this._getListItems();
|
this.$.cursor.stops = this._getListItems();
|
||||||
this.$.cursor.moveToStart();
|
this.$.cursor.moveToStart();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_isOutgoing(section) {
|
_isOutgoing(section) {
|
||||||
|
@@ -172,11 +172,11 @@ limitations under the License.
|
|||||||
{_number: 2},
|
{_number: 2},
|
||||||
];
|
];
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
Polymer.RenderStatus.afterNextRender(element, () => {
|
||||||
const elementItems = Polymer.dom(element.root).querySelectorAll(
|
const elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||||
'gr-change-list-item');
|
'gr-change-list-item');
|
||||||
assert.equal(elementItems.length, 3);
|
assert.equal(elementItems.length, 3);
|
||||||
|
|
||||||
flush(() => {
|
|
||||||
assert.isTrue(elementItems[0].hasAttribute('selected'));
|
assert.isTrue(elementItems[0].hasAttribute('selected'));
|
||||||
MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
|
MockInteractions.pressAndReleaseKeyOn(element, 74, null, 'j');
|
||||||
assert.equal(element.selectedIndex, 1);
|
assert.equal(element.selectedIndex, 1);
|
||||||
@@ -470,6 +470,7 @@ limitations under the License.
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
Polymer.RenderStatus.afterNextRender(element, () => {
|
||||||
const elementItems = Polymer.dom(element.root).querySelectorAll(
|
const elementItems = Polymer.dom(element.root).querySelectorAll(
|
||||||
'gr-change-list-item');
|
'gr-change-list-item');
|
||||||
assert.equal(elementItems.length, 9);
|
assert.equal(elementItems.length, 9);
|
||||||
@@ -507,6 +508,7 @@ limitations under the License.
|
|||||||
assert.equal(change.reviewed, false,
|
assert.equal(change.reviewed, false,
|
||||||
'Should mark change as unreviewed');
|
'Should mark change as unreviewed');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('highlight attribute is updated correctly', () => {
|
test('highlight attribute is updated correctly', () => {
|
||||||
element.changes = [
|
element.changes = [
|
||||||
|
Reference in New Issue
Block a user