PolymerElements / paper-icon-button

A Material Design icon button
https://www.webcomponents.org/element/PolymerElements/paper-icon-button
42 stars 44 forks source link

Paper-icon-button removes data-args parameters #95

Closed gabrielle-perez-movile closed 7 years ago

gabrielle-perez-movile commented 7 years ago

I am trying to call a function in on-tap parameter and I need to pass an object to this function (since this button is on a template repeat) but when I try to add a data-arg in the paper-icon-button element to get through e.currentTarget.getAttribute I am not able to get it because the parameters were removed.

<paper-icon-button
    icon="icons:content-copy"
    data-name="[[upperCaseFilter(item.name)]]"
    data-price="[[item.price.value]]"
    on-tap="_copy">
</paper-icon-button>

_copy: function(e){
    this.newObj = e.currentTarget.getAttribute('data-price');
},

Generated html:

<paper-icon-button icon="icons:content-copy" class="style-scope block-seats x-scope paper-icon-button-1" role="button" tabindex="0" aria-disabled="false" focused="">
gabrielle-perez-movile commented 7 years ago

I've found the problem...

The correct code is below:

<paper-icon-button
    icon="icons:content-copy"
    data-name$="[[upperCaseFilter(item.name)]]"
    data-price$="[[item.price.value]]"
    on-tap="_copy">
</paper-icon-button>

I didn't know the need of using $= in this scenario too...