polymer 1.0 - Access element on-tap handler from host element on-keypress handler -


i developing building block element a11y-icon used supporting accessibility. custom element should provide keyboard event handler when user presses key on icon.

<dom-module id="a11y-icon">     <template>         <iron-icon icon="{{icon}}" style="{{style}}" tabindex="0" role="button" aria-label$="{{description}}" on-keypress="_keypresshandler"></iron-icon>     </template> </dom-module> <script>     polymer({         is: "a11y-icon",         properties: {             icon: string,             style: string,             description: string         },         _keypresshandler: function(event) {             var code = event.keycode;             // accept enter or spacebar key             if (code == 13 || code == 32) {                 // todo: call on-tap handler defined in element uses a11y-icon             }         }     }); </script> 

when developer uses a11y-icon element , provides on-tap handler, want a11y-icon _keypresshandler call on-tap handler.

<a11y-icon class="clickable" icon="icons:close" description="close item" on-tap="_closeitem"> 

my question how invoke element on-tap handler (e.g. _closeitem) host element handler (e.g. _keypresshandler)? assume polymer uses internal data-binding store on-tap handler somewhere.

by browsing polymer.html, found way invoke on-tap handler inside keypress handler -

    _keypresshandler: function(event) {         var code = event.keycode;         // accept enter or spacebar key         if (code == 13 || code == 32) {             this.fire("tap", event.currenttarget, event);         }     } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -