@ -17,7 +17,7 @@ export class CompileControl {
|
||||
constructor(public _steps: List<CompileStep>) {}
|
||||
|
||||
// only public so that it can be used by compile_pipeline
|
||||
internalProcess(results: any[], startStepIndex, parent: CompileElement,
|
||||
internalProcess(results: any[], startStepIndex: number, parent: CompileElement,
|
||||
current: CompileElement): CompileElement[] {
|
||||
this._results = results;
|
||||
var previousStepIndex = this._currentStepIndex;
|
||||
|
@ -17,7 +17,7 @@ export class CompilePipeline {
|
||||
this._control = new CompileControl(steps);
|
||||
}
|
||||
|
||||
process(rootElement, protoViewType: ViewType = null,
|
||||
process(rootElement: HTMLElement, protoViewType: ViewType = null,
|
||||
compilationCtxtDescription: string = ''): List<CompileElement> {
|
||||
if (isBlank(protoViewType)) {
|
||||
protoViewType = ViewType.COMPONENT;
|
||||
|
@ -36,6 +36,7 @@ export class DomCompiler extends RenderCompiler {
|
||||
return PromiseWrapper.then(
|
||||
tplPromise, (el) => this._compileTemplate(view, el, ViewType.COMPONENT), (e) => {
|
||||
throw new BaseException(`Failed to load the template for "${view.componentId}" : ${e}`);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ export class SelectorMatcher {
|
||||
* @param matchedCallback This callback will be called with the object handed into `addSelectable`
|
||||
* @return boolean true if a match was found
|
||||
*/
|
||||
match(cssSelector: CssSelector, matchedCallback /*: (CssSelector, any) => void*/): boolean {
|
||||
match(cssSelector: CssSelector, matchedCallback: (CssSelector, any) => void): boolean {
|
||||
var result = false;
|
||||
var element = cssSelector.element;
|
||||
var classNames = cssSelector.classNames;
|
||||
@ -353,7 +353,7 @@ export class SelectorContext {
|
||||
this.notSelectors = selector.notSelectors;
|
||||
}
|
||||
|
||||
finalize(cssSelector: CssSelector, callback /*: (CssSelector, any) => void*/): boolean {
|
||||
finalize(cssSelector: CssSelector, callback: (CssSelector, any) => void): boolean {
|
||||
var result = true;
|
||||
if (this.notSelectors.length > 0 &&
|
||||
(isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
|
||||
|
@ -22,14 +22,15 @@ export class TextInterpolationParser implements CompileStep {
|
||||
for (var i = 0; i < childNodes.length; i++) {
|
||||
var node = childNodes[i];
|
||||
if (DOM.isTextNode(node)) {
|
||||
var text = DOM.nodeValue(node);
|
||||
var textNode = <Text>node;
|
||||
var text = DOM.nodeValue(textNode);
|
||||
var expr = this._parser.parseInterpolation(text, current.elementDescription);
|
||||
if (isPresent(expr)) {
|
||||
DOM.setText(node, ' ');
|
||||
DOM.setText(textNode, ' ');
|
||||
if (current.element === current.inheritedProtoView.rootElement) {
|
||||
current.inheritedProtoView.bindRootText(node, expr);
|
||||
current.inheritedProtoView.bindRootText(textNode, expr);
|
||||
} else {
|
||||
current.bindElement().bindText(node, expr);
|
||||
current.bindElement().bindText(textNode, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ export class EventManager {
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener(element, eventName: string, handler: Function) {
|
||||
addEventListener(element: HTMLElement, eventName: string, handler: Function) {
|
||||
var withoutBubbleSymbol = this._removeBubbleSymbol(eventName);
|
||||
var plugin = this._findPluginFor(withoutBubbleSymbol);
|
||||
plugin.addEventListener(element, withoutBubbleSymbol, handler,
|
||||
@ -53,11 +53,12 @@ export class EventManagerPlugin {
|
||||
// addEventListener methods.
|
||||
supports(eventName: string): boolean { return false; }
|
||||
|
||||
addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
|
||||
addEventListener(element: HTMLElement, eventName: string, handler: Function,
|
||||
shouldSupportBubble: boolean) {
|
||||
throw "not implemented";
|
||||
}
|
||||
|
||||
addGlobalEventListener(element, eventName: string, handler: Function,
|
||||
addGlobalEventListener(element: string, eventName: string, handler: Function,
|
||||
shouldSupportBubble: boolean): Function {
|
||||
throw "not implemented";
|
||||
}
|
||||
@ -70,7 +71,8 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
||||
// events.
|
||||
supports(eventName: string): boolean { return true; }
|
||||
|
||||
addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
|
||||
addEventListener(element: HTMLElement, eventName: string, handler: Function,
|
||||
shouldSupportBubble: boolean) {
|
||||
var outsideHandler =
|
||||
this._getOutsideHandler(shouldSupportBubble, element, handler, this.manager._zone);
|
||||
this.manager._zone.runOutsideAngular(() => { DOM.on(element, eventName, outsideHandler); });
|
||||
@ -85,12 +87,14 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
||||
() => { return DOM.onAndCancel(element, eventName, outsideHandler); });
|
||||
}
|
||||
|
||||
_getOutsideHandler(shouldSupportBubble: boolean, element, handler: Function, zone: NgZone) {
|
||||
_getOutsideHandler(shouldSupportBubble: boolean, element: HTMLElement, handler: Function,
|
||||
zone: NgZone) {
|
||||
return shouldSupportBubble ? DomEventsPlugin.bubbleCallback(element, handler, zone) :
|
||||
DomEventsPlugin.sameElementCallback(element, handler, zone);
|
||||
}
|
||||
|
||||
static sameElementCallback(element, handler, zone): (event: Event) => void {
|
||||
static sameElementCallback(element: HTMLElement, handler: Function, zone: NgZone):
|
||||
(event: Event) => void {
|
||||
return (event) => {
|
||||
if (event.target === element) {
|
||||
zone.run(() => handler(event));
|
||||
@ -98,7 +102,8 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
||||
};
|
||||
}
|
||||
|
||||
static bubbleCallback(element, handler, zone): (event: Event) => void {
|
||||
static bubbleCallback(element: HTMLElement, handler: Function, zone: NgZone):
|
||||
(event: Event) => void {
|
||||
return (event) => zone.run(() => handler(event));
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ export class HammerGesturesPlugin extends HammerGesturesPluginCommon {
|
||||
return true;
|
||||
}
|
||||
|
||||
addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
|
||||
addEventListener(element: HTMLElement, eventName: string, handler: Function,
|
||||
shouldSupportBubble: boolean) {
|
||||
if (shouldSupportBubble)
|
||||
throw new BaseException('Hammer.js plugin does not support bubbling gestures.');
|
||||
var zone = this.manager.getZone();
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {EventManagerPlugin} from './event_manager';
|
||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
|
||||
var modifierKeys = ['alt', 'control', 'meta', 'shift'];
|
||||
var modifierKeyGetters: StringMap<string, Function> = {
|
||||
@ -25,7 +26,8 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
||||
return isPresent(KeyEventsPlugin.parseEventName(eventName));
|
||||
}
|
||||
|
||||
addEventListener(element, eventName: string, handler: Function, shouldSupportBubble: boolean) {
|
||||
addEventListener(element: HTMLElement, eventName: string, handler: (Event: any) => any,
|
||||
shouldSupportBubble: boolean) {
|
||||
var parsedEvent = KeyEventsPlugin.parseEventName(eventName);
|
||||
|
||||
var outsideHandler = KeyEventsPlugin.eventCallback(element, shouldSupportBubble,
|
||||
@ -68,7 +70,7 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
||||
return result;
|
||||
}
|
||||
|
||||
static getEventFullKey(event): string {
|
||||
static getEventFullKey(event: Event): string {
|
||||
var fullKey = '';
|
||||
var key = DOM.getEventKey(event);
|
||||
key = key.toLowerCase();
|
||||
@ -89,8 +91,8 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
||||
return fullKey;
|
||||
}
|
||||
|
||||
static eventCallback(element, shouldSupportBubble, fullKey, handler, zone):
|
||||
(event: Event) => void {
|
||||
static eventCallback(element: HTMLElement, shouldSupportBubble: boolean, fullKey: any,
|
||||
handler: (Event) => any, zone: NgZone): (event: Event) => void {
|
||||
return (event) => {
|
||||
var correctElement = shouldSupportBubble || event.target === element;
|
||||
if (correctElement && StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
export class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomStrategy {
|
||||
constructor(styleHost) { super(styleHost); }
|
||||
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleEl): void {
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleEl: Element): void {
|
||||
let cssText = DOM.getText(styleEl);
|
||||
cssText = shimCssForComponent(cssText, hostComponentId);
|
||||
DOM.setText(styleEl, cssText);
|
||||
@ -38,7 +38,7 @@ export class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomSt
|
||||
insertStyleElement(this.styleHost, styleEl);
|
||||
}
|
||||
|
||||
processElement(hostComponentId: string, elementComponentId: string, element): void {
|
||||
processElement(hostComponentId: string, elementComponentId: string, element: Element): void {
|
||||
// Shim the element as a child of the compiled component
|
||||
if (isPresent(hostComponentId)) {
|
||||
var contentAttribute = getContentAttribute(getComponentId(hostComponentId));
|
||||
|
@ -17,7 +17,7 @@ export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy {
|
||||
|
||||
hasNativeContentElement(): boolean { return false; }
|
||||
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleEl): void {
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleEl: Element): void {
|
||||
var cssText = DOM.getText(styleEl);
|
||||
insertSharedStyleText(cssText, this.styleHost, styleEl);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ export class ShadowCss {
|
||||
* Shim a style element with the given selector. Returns cssText that can
|
||||
* be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
|
||||
*/
|
||||
shimStyle(style, selector: string, hostSelector: string = ''): string {
|
||||
shimStyle(style: string, selector: string, hostSelector: string = ''): string {
|
||||
var cssText = DOM.getText(style);
|
||||
return this.shimCssText(cssText, selector, hostSelector);
|
||||
}
|
||||
|
@ -5,8 +5,9 @@ export class ShadowDomStrategy {
|
||||
hasNativeContentElement(): boolean { return true; }
|
||||
|
||||
// An optional step that can modify the template style elements.
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleElement): void {}
|
||||
processStyleElement(hostComponentId: string, templateUrl: string, styleElement: HTMLStyleElement):
|
||||
void {}
|
||||
|
||||
// An optional step that can modify the template elements (style elements exlcuded).
|
||||
processElement(hostComponentId: string, elementComponentId: string, element): void {}
|
||||
processElement(hostComponentId: string, elementComponentId: string, element: HTMLElement): void {}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export class ProtoViewBuilder {
|
||||
constructor(public rootElement, public type: api.ViewType,
|
||||
public useNativeShadowDom: boolean = false) {}
|
||||
|
||||
bindElement(element, description = null): ElementBinderBuilder {
|
||||
bindElement(element: HTMLElement, description: string = null): ElementBinderBuilder {
|
||||
var builder = new ElementBinderBuilder(this.elements.length, element, description);
|
||||
this.elements.push(builder);
|
||||
DOM.addClass(element, NG_BINDING_CLASS);
|
||||
@ -41,7 +41,7 @@ export class ProtoViewBuilder {
|
||||
return builder;
|
||||
}
|
||||
|
||||
bindVariable(name, value) {
|
||||
bindVariable(name: string, value: string) {
|
||||
// Store the variable map from value to variable, reflecting how it will be used later by
|
||||
// DomView. When a local is set to the view, a lookup for the variable name will take place
|
||||
// keyed
|
||||
@ -53,7 +53,9 @@ export class ProtoViewBuilder {
|
||||
|
||||
// Note: We don't store the node index until the compilation is complete,
|
||||
// as the compiler might change the order of elements.
|
||||
bindRootText(textNode, expression) { this.rootTextBindings.set(textNode, expression); }
|
||||
bindRootText(textNode: Text, expression: ASTWithSource) {
|
||||
this.rootTextBindings.set(textNode, expression);
|
||||
}
|
||||
|
||||
build(): api.ProtoViewDto {
|
||||
var domElementBinders = [];
|
||||
@ -140,7 +142,7 @@ export class ElementBinderBuilder {
|
||||
|
||||
constructor(public index: number, public element, description: string) {}
|
||||
|
||||
setParent(parent: ElementBinderBuilder, distanceToParent): ElementBinderBuilder {
|
||||
setParent(parent: ElementBinderBuilder, distanceToParent: number): ElementBinderBuilder {
|
||||
this.parent = parent;
|
||||
if (isPresent(parent)) {
|
||||
this.distanceToParent = distanceToParent;
|
||||
@ -160,7 +162,7 @@ export class ElementBinderBuilder {
|
||||
return directive;
|
||||
}
|
||||
|
||||
bindNestedProtoView(rootElement): ProtoViewBuilder {
|
||||
bindNestedProtoView(rootElement: HTMLElement): ProtoViewBuilder {
|
||||
if (isPresent(this.nestedProtoView)) {
|
||||
throw new BaseException('Only one nested view per element is allowed');
|
||||
}
|
||||
@ -178,7 +180,7 @@ export class ElementBinderBuilder {
|
||||
this.propertyBindingsToDirectives.add(name);
|
||||
}
|
||||
|
||||
bindVariable(name, value) {
|
||||
bindVariable(name: string, value: string) {
|
||||
// When current is a view root, the variable bindings are set to the *nested* proto view.
|
||||
// The root view conceptually signifies a new "block scope" (the nested view), to which
|
||||
// the variables are bound.
|
||||
@ -196,13 +198,15 @@ export class ElementBinderBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
bindEvent(name, expression, target = null) {
|
||||
bindEvent(name: string, expression: ASTWithSource, target: string = null) {
|
||||
this.eventBindings.push(this.eventBuilder.add(name, expression, target));
|
||||
}
|
||||
|
||||
// Note: We don't store the node index until the compilation is complete,
|
||||
// as the compiler might change the order of elements.
|
||||
bindText(textNode, expression) { this.textBindings.set(textNode, expression); }
|
||||
bindText(textNode: Text, expression: ASTWithSource) {
|
||||
this.textBindings.set(textNode, expression);
|
||||
}
|
||||
|
||||
setComponentId(componentId: string) { this.componentId = componentId; }
|
||||
}
|
||||
@ -231,7 +235,7 @@ export class DirectiveBuilder {
|
||||
this.hostPropertyBindings.set(name, expression);
|
||||
}
|
||||
|
||||
bindEvent(name, expression, target = null) {
|
||||
bindEvent(name: string, expression: ASTWithSource, target: string = null) {
|
||||
this.eventBindings.push(this.eventBuilder.add(name, expression, target));
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ export class DomView {
|
||||
|
||||
setText(textIndex: number, value: string) { DOM.setText(this.boundTextNodes[textIndex], value); }
|
||||
|
||||
dispatchEvent(elementIndex, eventName, event): boolean {
|
||||
dispatchEvent(elementIndex: number, eventName: string, event: Event): boolean {
|
||||
var allowDefaultBehavior = true;
|
||||
if (isPresent(this.eventDispatcher)) {
|
||||
var evalLocals = new Map();
|
||||
|
Reference in New Issue
Block a user