fix(events): extract eventHandler to new function scope.

This commit is contained in:
Rado Kirov 2015-01-16 16:30:43 -08:00
parent 2381c3640b
commit 7f701da66f
1 changed files with 16 additions and 12 deletions

View File

@ -379,6 +379,18 @@ export class ProtoView {
// TODO(rado): if there is directive at this element that injected an
// event emitter for that eventType do not attach the handler.
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) => {
if (event.target === element) {
// 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);
}
});
});
}
}
view.init(elementInjectors, rootElementInjectors, textNodes, elementsWithPropertyBindings,
viewPorts, preBuiltObjects, componentChildViews);
return view;
}
_parentElementLightDom(protoElementInjector:ProtoElementInjector, preBuiltObjects:List):LightDom {