PolymerElements / paper-button

A button à la Material Design
https://www.webcomponents.org/element/PolymerElements/paper-button
138 stars 64 forks source link

Polymer dom does not normalize paper-button's localTarget #106

Closed Typel closed 8 years ago

Typel commented 8 years ago

Given the following situation:

<paper-button on-tap="_doSomething" id="button">Click Here <iron-icon id="icon" icon="icons:expand-more"></iron-icon></paper-button>
...
app._doSomething = function(e) {
  console.log(Polymer.dom(e).localTarget.id);
};

Clicking on the button in various locations logs an assortment of values to the console, back and forth between "button" and "icon" depending on where the button is clicked. It was my understanding that Polymer.dom should normalize the tap's source to the element's underlying button as it does with paper-fab. Is this normal behavior for paper-button or should this be fixed?

Thank you.

keanulee commented 8 years ago

@Typel This is normal behavior - the <iron-icon> is in the light DOM (i.e. you created this <iron-icon> element and passing it to <paper-button>), so it is local to you and that's what the API should return (if you did indeed click the icon). In <paper-fab>'s case, the icon is in paper-fab's local DOM (i.e. you didn't declare the iron-icon - that is an implementation detail of paper-fab) so you shouldn't see that in the normalized event.