polymer Event Handling Event Retargeting


Example

It is possible to retarget an event in Polymer ie you can change event details like path thus hiding the actual details of an event/element from user.

For e.g if a div inside event-retargeting element is firing the event but developer does not want the user to know that he can retarget the event to event-retargeting element by using the following code.

var targetEl = document.querySelector('event-retargeting');
var normalizedEvent = Polymer.dom(event);
normalizedEvent.rootTarget = targetEl;
normalizedEvent.localTarget =targetEl
normalizedEvent.path = [];
normalizedEvent.path.push(targetEl);
normalizedEvent.path.push(document.querySelector('body'));
normalizedEvent.path.push(document.querySelector('html')); 

To see the working example please refer to plunker in remarks section.