fix(events): extract eventHandler to new function scope.
This commit is contained in:
parent
2381c3640b
commit
7f701da66f
|
@ -379,6 +379,18 @@ export class ProtoView {
|
||||||
// TODO(rado): if there is directive at this element that injected an
|
// TODO(rado): if there is directive at this element that injected an
|
||||||
// event emitter for that eventType do not attach the handler.
|
// event emitter for that eventType do not attach the handler.
|
||||||
MapWrapper.forEach(binder.events, (expr, eventName) => {
|
MapWrapper.forEach(binder.events, (expr, eventName) => {
|
||||||
|
ProtoView._addNativeEventListener(element, eventName, expr, view);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view.init(elementInjectors, rootElementInjectors, textNodes, elementsWithPropertyBindings,
|
||||||
|
viewPorts, preBuiltObjects, componentChildViews);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _addNativeEventListener(element: Element, eventName: string, expr, view: View) {
|
||||||
DOM.on(element, eventName, (event) => {
|
DOM.on(element, eventName, (event) => {
|
||||||
if (event.target === element) {
|
if (event.target === element) {
|
||||||
// Most of the time the event will be fired only when the view is
|
// Most of the time the event will be fired only when the view is
|
||||||
|
@ -391,14 +403,6 @@ export class ProtoView {
|
||||||
if (view.hydrated()) expr.eval(view.context);
|
if (view.hydrated()) expr.eval(view.context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view.init(elementInjectors, rootElementInjectors, textNodes, elementsWithPropertyBindings,
|
|
||||||
viewPorts, preBuiltObjects, componentChildViews);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_parentElementLightDom(protoElementInjector:ProtoElementInjector, preBuiltObjects:List):LightDom {
|
_parentElementLightDom(protoElementInjector:ProtoElementInjector, preBuiltObjects:List):LightDom {
|
||||||
|
|
Loading…
Reference in New Issue