Assume this template
<ul>
<li !if="exp" (tap)="doSomething()"></li>
<ul>
Here the li will get turned into:
<template>
<li !if="exp" (tap)="doSomething()"></li>
</template>
Once the View of the if gets instantiated it will attempt to register a tap event on Hammer. The issue is that the element is a clone of the <template> and is not yet inserted into the main document for rendering. Hammer will than try to register a listener on the wrong document, which is null.
(See hammer.js)
function getWindowForElement(element) {
var doc = element.ownerDocument;
return (doc.defaultView || doc.parentWindow);
}
The issue is that the doc.defaultView is null since the ownerDocument is that of the template and not of the main document.
Proposed Fix
Use document.importNode(element, true) instead of element.cloneNode(true)
Assume this template
Here the
liwill get turned into:Once the
Viewof theifgets instantiated it will attempt to register atapevent onHammer. The issue is that the element is a clone of the<template>and is not yet inserted into the main document for rendering.Hammerwill than try to register a listener on the wrong document, which is null.(See
hammer.js)The issue is that the
doc.defaultViewis null since theownerDocumentis that of thetemplateand not of the main document.Proposed Fix
Use
document.importNode(element, true)instead ofelement.cloneNode(true)