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) {
const index = e.target.dataIndex;
const index = Polymer.dom(e).localTarget.dataIndex;
if (index === 0) { return; }
const row = this.menuItems[index];
const prev = this.menuItems[index - 1];
@ -32,7 +32,7 @@
},
_handleMoveDownButton(e) {
const index = e.target.dataIndex;
const index = Polymer.dom(e).localTarget.dataIndex;
if (index === this.menuItems.length - 1) { return; }
const row = this.menuItems[index];
const next = this.menuItems[index + 1];
@ -40,7 +40,7 @@
},
_handleDeleteButton(e) {
const index = e.target.dataIndex;
const index = Polymer.dom(e).localTarget.dataIndex;
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.
// The index of the first row is 0, corresponding to the array.
function move(element, index, direction) {
const selector =
'tr:nth-child(' + (index + 1) + ') .move' + direction + 'Button';
const button = element.$$('tbody').querySelector(selector);
const selector = 'tr:nth-child(' + (index + 1) + ') .move' +
direction + 'Button';
const button =
element.$$('tbody').querySelector(selector).$$('paper-button');
MockInteractions.tap(button);
}
@ -141,15 +142,15 @@ limitations under the License.
['first name', 'second name', 'third name']);
// Tap the delete button for the middle item.
MockInteractions.tap(
element.$$('tbody').querySelector('tr:nth-child(2) .remove-button'));
MockInteractions.tap(element.$$('tbody')
.querySelector('tr:nth-child(2) .remove-button').$$('paper-button'));
assertMenuNamesEqual(element, ['first name', 'third name']);
// Delete remaining items.
for (let i = 0; i < 2; i++) {
MockInteractions.tap(
element.$$('tbody').querySelector('tr:first-child .remove-button'));
MockInteractions.tap(element.$$('tbody')
.querySelector('tr:first-child .remove-button').$$('paper-button'));
}
assertMenuNamesEqual(element, []);