Merge "Fix event targeting in menu-editor" into stable-2.15

This commit is contained in:
Becky Siegel 2018-02-26 20:27:30 +00:00 committed by Gerrit Code Review
commit cba2cf5d5b
2 changed files with 11 additions and 10 deletions

View File

@ -24,7 +24,7 @@
}, },
_handleMoveUpButton(e) { _handleMoveUpButton(e) {
const index = e.target.dataIndex; const index = Polymer.dom(e).localTarget.dataIndex;
if (index === 0) { return; } if (index === 0) { return; }
const row = this.menuItems[index]; const row = this.menuItems[index];
const prev = this.menuItems[index - 1]; const prev = this.menuItems[index - 1];
@ -32,7 +32,7 @@
}, },
_handleMoveDownButton(e) { _handleMoveDownButton(e) {
const index = e.target.dataIndex; const index = Polymer.dom(e).localTarget.dataIndex;
if (index === this.menuItems.length - 1) { return; } if (index === this.menuItems.length - 1) { return; }
const row = this.menuItems[index]; const row = this.menuItems[index];
const next = this.menuItems[index + 1]; const next = this.menuItems[index + 1];
@ -40,7 +40,7 @@
}, },
_handleDeleteButton(e) { _handleDeleteButton(e) {
const index = e.target.dataIndex; const index = Polymer.dom(e).localTarget.dataIndex;
this.splice('menuItems', index, 1); this.splice('menuItems', index, 1);
}, },

View File

@ -47,9 +47,10 @@ limitations under the License.
// Click the up/down button (according to direction) for the index'th row. // Click the up/down button (according to direction) for the index'th row.
// The index of the first row is 0, corresponding to the array. // The index of the first row is 0, corresponding to the array.
function move(element, index, direction) { function move(element, index, direction) {
const selector = const selector = 'tr:nth-child(' + (index + 1) + ') .move' +
'tr:nth-child(' + (index + 1) + ') .move' + direction + 'Button'; direction + 'Button';
const button = element.$$('tbody').querySelector(selector); const button =
element.$$('tbody').querySelector(selector).$$('paper-button');
MockInteractions.tap(button); MockInteractions.tap(button);
} }
@ -141,15 +142,15 @@ limitations under the License.
['first name', 'second name', 'third name']); ['first name', 'second name', 'third name']);
// Tap the delete button for the middle item. // Tap the delete button for the middle item.
MockInteractions.tap( MockInteractions.tap(element.$$('tbody')
element.$$('tbody').querySelector('tr:nth-child(2) .remove-button')); .querySelector('tr:nth-child(2) .remove-button').$$('paper-button'));
assertMenuNamesEqual(element, ['first name', 'third name']); assertMenuNamesEqual(element, ['first name', 'third name']);
// Delete remaining items. // Delete remaining items.
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
MockInteractions.tap( MockInteractions.tap(element.$$('tbody')
element.$$('tbody').querySelector('tr:first-child .remove-button')); .querySelector('tr:first-child .remove-button').$$('paper-button'));
} }
assertMenuNamesEqual(element, []); assertMenuNamesEqual(element, []);