Update e.currentTarget to Polymer.dom(e).localTarget

This does essentially the same thing, but uses event retargetting to
simulate event.target under shadow DOM. This acts the same as
currentTarget because the node is always in the same scope as the node
where the listener was added. This is polyfilled to work in older
browsers than e.currentTarget and is less likely to have issues with
shadow DOM.

https://www.polymer-project.org/1.0/docs/devguide/events#retargeting

Change-Id: I6fe5afdfddfdc3e21fbca10aef260cac704bea3d
This commit is contained in:
Becky Siegel
2017-10-11 17:04:14 -07:00
parent c98af21c4b
commit 5b62347cf4
4 changed files with 6 additions and 5 deletions

View File

@@ -666,7 +666,7 @@
_handleActionTap(e) {
e.preventDefault();
const el = e.currentTarget;
const el = Polymer.dom(e).localTarget;
const key = el.getAttribute('data-action-key');
if (key.startsWith(ADDITIONAL_ACTION_KEY_PREFIX)) {
this.fire(`${key}-tap`, {node: el});

View File

@@ -62,7 +62,8 @@
},
_handleDeleteButton(e) {
const index = parseInt(e.currentTarget.getAttribute('data-index'), 10);
const index = parseInt(Polymer.dom(e).localTarget
.getAttribute('data-index'), 10);
const email = this._emails[index];
this.push('_emailsToRemove', email);
this.splice('_emails', index, 1);

View File

@@ -58,7 +58,7 @@
},
_showKey(e) {
const el = e.currentTarget;
const el = Polymer.dom(e).localTarget;
const index = parseInt(el.getAttribute('data-index'), 10);
this._keyToView = this._keys[index];
this.$.viewKeyOverlay.open();
@@ -69,7 +69,7 @@
},
_handleDeleteKey(e) {
const el = e.currentTarget;
const el = Polymer.dom(e).localTarget;
const index = parseInt(el.getAttribute('data-index'), 10);
this.push('_keysToRemove', this._keys[index]);
this.splice('_keys', index, 1);

View File

@@ -64,7 +64,7 @@
_handleSchemeTap(e) {
e.preventDefault();
const el = e.currentTarget;
const el = Polymer.dom(e).localTarget;
this.selectedScheme = el.getAttribute('data-scheme');
if (this._loggedIn) {
this.$.restAPI.savePreferences({download_scheme: this.selectedScheme});