chore: adjust formatting to new clang-format.

- fixes wrapping for object literal keys called `template`.
- spacing in destructuring expressions.
- changes to keep trailing return types of functions closer to their
  function declaration.
- better formatting of string literals.

Closes #4828
This commit is contained in:
Martin Probst 2015-10-28 08:59:19 +01:00
parent 4a1b873fad
commit c02f2bdab0
50 changed files with 245 additions and 236 deletions

View File

@ -18,9 +18,9 @@ export {
} from './application_ref'; } from './application_ref';
/// See [commonBootstrap] for detailed documentation. /// See [commonBootstrap] for detailed documentation.
export function bootstrap(appComponentType: /*Type*/ any, export function bootstrap(
appProviders: Array<Type | Provider | any[]> = null): appComponentType: /*Type*/ any,
Promise<ComponentRef> { appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
var providers = [compilerProviders()]; var providers = [compilerProviders()];
if (isPresent(appProviders)) { if (isPresent(appProviders)) {
providers.push(appProviders); providers.push(appProviders);

View File

@ -218,9 +218,9 @@ export function platform(providers?: Array<Type | Provider | any[]>): PlatformRe
* *
* Returns a `Promise` of {@link ComponentRef}. * Returns a `Promise` of {@link ComponentRef}.
*/ */
export function commonBootstrap(appComponentType: /*Type*/ any, export function commonBootstrap(
appProviders: Array<Type | Provider | any[]> = null): appComponentType: /*Type*/ any,
Promise<ComponentRef> { appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
var p = platform(); var p = platform();
var bindings = [applicationCommonProviders(), applicationDomProviders()]; var bindings = [applicationCommonProviders(), applicationDomProviders()];
if (isPresent(appProviders)) { if (isPresent(appProviders)) {

View File

@ -203,8 +203,8 @@ export abstract class PlatformRef {
* new application. Once this promise resolves, the application will be * new application. Once this promise resolves, the application will be
* constructed in the same manner as a normal `application()`. * constructed in the same manner as a normal `application()`.
*/ */
abstract asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>): abstract asyncApplication(bindingFn: (zone: NgZone) =>
Promise<ApplicationRef>; Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef>;
/** /**
* Destroy the Angular platform and all Angular applications on the page. * Destroy the Angular platform and all Angular applications on the page.
@ -228,8 +228,8 @@ export class PlatformRef_ extends PlatformRef {
return app; return app;
} }
asyncApplication(bindingFn: (zone: NgZone) => asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>):
Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef> { Promise<ApplicationRef> {
var zone = createNgZone(); var zone = createNgZone();
var completer = PromiseWrapper.completer(); var completer = PromiseWrapper.completer();
zone.run(() => { zone.run(() => {
@ -314,8 +314,8 @@ export abstract class ApplicationRef {
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]); * app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
* ``` * ```
*/ */
abstract bootstrap(componentType: Type, providers?: Array<Type | Provider | any[]>): abstract bootstrap(componentType: Type,
Promise<ComponentRef>; providers?: Array<Type | Provider | any[]>): Promise<ComponentRef>;
/** /**
* Retrieve the application {@link Injector}. * Retrieve the application {@link Injector}.

View File

@ -51,8 +51,8 @@ export var CHANGE_DETECTION_STRATEGY_VALUES = [
ChangeDetectionStrategy.OnPushObserve ChangeDetectionStrategy.OnPushObserve
]; ];
export function isDefaultChangeDetectionStrategy(changeDetectionStrategy: ChangeDetectionStrategy): export function isDefaultChangeDetectionStrategy(
boolean { changeDetectionStrategy: ChangeDetectionStrategy): boolean {
return isBlank(changeDetectionStrategy) || return isBlank(changeDetectionStrategy) ||
changeDetectionStrategy === ChangeDetectionStrategy.Default; changeDetectionStrategy === ChangeDetectionStrategy.Default;
} }

View File

@ -200,8 +200,8 @@ class CodegenCommandFactory implements CommandFactory<string> {
} }
} }
function visitAndReturnContext(visitor: TemplateAstVisitor, asts: TemplateAst[], context: any): function visitAndReturnContext(visitor: TemplateAstVisitor, asts: TemplateAst[],
any { context: any): any {
templateVisitAll(visitor, asts, context); templateVisitAll(visitor, asts, context);
return context; return context;
} }

View File

@ -159,7 +159,8 @@ export class CompileDirectiveMetadata {
hostListeners: hostListeners, hostListeners: hostListeners,
hostProperties: hostProperties, hostProperties: hostProperties,
hostAttributes: hostAttributes, hostAttributes: hostAttributes,
lifecycleHooks: isPresent(lifecycleHooks) ? lifecycleHooks : [], template: template lifecycleHooks: isPresent(lifecycleHooks) ? lifecycleHooks : [],
template: template
}); });
} }

View File

@ -40,16 +40,16 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string):
`${parentSourceInfo} > #text(${value}):nth-child(${indexInParent})`); `${parentSourceInfo} > #text(${value}):nth-child(${indexInParent})`);
} }
function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string): function parseAttr(element: Element, parentSourceInfo: string, attrName: string,
HtmlAttrAst { attrValue: string): HtmlAttrAst {
// TODO(tbosch): add source row/column source info from parse5 / package:html // TODO(tbosch): add source row/column source info from parse5 / package:html
var lowerCaseAttrName = attrName.toLowerCase(); var lowerCaseAttrName = attrName.toLowerCase();
return new HtmlAttrAst(lowerCaseAttrName, attrValue, return new HtmlAttrAst(lowerCaseAttrName, attrValue,
`${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`); `${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`);
} }
function parseElement(element: Element, indexInParent: number, parentSourceInfo: string): function parseElement(element: Element, indexInParent: number,
HtmlElementAst { parentSourceInfo: string): HtmlElementAst {
// normalize nodename always as lower case so that following build steps // normalize nodename always as lower case so that following build steps
// can rely on this // can rely on this
var nodeName = DOM.nodeName(element).toLowerCase(); var nodeName = DOM.nodeName(element).toLowerCase();

View File

@ -24,8 +24,8 @@ export function isStyleUrlResolvable(url: string): boolean {
* Rewrites stylesheets by resolving and removing the @import urls that * Rewrites stylesheets by resolving and removing the @import urls that
* are either relative or don't have a `package:` scheme * are either relative or don't have a `package:` scheme
*/ */
export function extractStyleUrls(resolver: UrlResolver, baseUrl: string, cssText: string): export function extractStyleUrls(resolver: UrlResolver, baseUrl: string,
StyleWithImports { cssText: string): StyleWithImports {
var foundUrls = []; var foundUrls = [];
var modifiedCssText = StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m) => { var modifiedCssText = StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m) => {
var url = isPresent(m[1]) ? m[1] : m[2]; var url = isPresent(m[1]) ? m[1] : m[2];

View File

@ -50,8 +50,8 @@ export class TemplateCompiler {
this._appId = appId; this._appId = appId;
} }
normalizeDirectiveMetadata(directive: normalizeDirectiveMetadata(directive: CompileDirectiveMetadata):
CompileDirectiveMetadata): Promise<CompileDirectiveMetadata> { Promise<CompileDirectiveMetadata> {
if (!directive.isComponent) { if (!directive.isComponent) {
// For non components there is nothing to be normalized yet. // For non components there is nothing to be normalized yet.
return PromiseWrapper.resolve(directive); return PromiseWrapper.resolve(directive);
@ -70,7 +70,8 @@ export class TemplateCompiler {
hostListeners: directive.hostListeners, hostListeners: directive.hostListeners,
hostProperties: directive.hostProperties, hostProperties: directive.hostProperties,
hostAttributes: directive.hostAttributes, hostAttributes: directive.hostAttributes,
lifecycleHooks: directive.lifecycleHooks, template: normalizedTemplate lifecycleHooks: directive.lifecycleHooks,
template: normalizedTemplate
})); }));
} }

View File

@ -686,8 +686,8 @@ function _extractToken(typeOrFunc, metadata /*any[] | any*/, params: any[][]): D
} }
} }
function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps): function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility,
Dependency { depProps): Dependency {
return new Dependency(Key.get(token), optional, lowerBoundVisibility, upperBoundVisibility, return new Dependency(Key.get(token), optional, lowerBoundVisibility, upperBoundVisibility,
depProps); depProps);
} }

View File

@ -61,8 +61,9 @@ var _clearValues: {(m: Map<any, any>)} = (function() {
var _arrayFromMap: {(m: Map<any, any>, getValues: boolean): any[]} = (function() { var _arrayFromMap: {(m: Map<any, any>, getValues: boolean): any[]} = (function() {
try { try {
if ((<any>(new Map()).values()).next) { if ((<any>(new Map()).values()).next) {
return function createArrayFromMap(m: Map<any, any>, getValues: boolean): return function createArrayFromMap(m: Map<any, any>, getValues: boolean): any[] {
any[] { return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys()); }; return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys());
};
} }
} catch (e) { } catch (e) {
} }

View File

@ -68,8 +68,8 @@ export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any)
} }
// TODO: vsavkin remove it once https://github.com/angular/angular/issues/3011 is implemented // TODO: vsavkin remove it once https://github.com/angular/angular/issues/3011 is implemented
export function selectValueAccessor(dir: NgControl, valueAccessors: ControlValueAccessor[]): export function selectValueAccessor(dir: NgControl,
ControlValueAccessor { valueAccessors: ControlValueAccessor[]): ControlValueAccessor {
if (isBlank(valueAccessors)) return null; if (isBlank(valueAccessors)) return null;
var defaultAccessor; var defaultAccessor;

View File

@ -111,8 +111,8 @@ export abstract class AbstractControl {
setParent(parent: ControlGroup | ControlArray): void { this._parent = parent; } setParent(parent: ControlGroup | ControlArray): void { this._parent = parent; }
updateValueAndValidity({onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}): updateValueAndValidity(
void { {onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}): void {
onlySelf = normalizeBool(onlySelf); onlySelf = normalizeBool(onlySelf);
emitEvent = isPresent(emitEvent) ? emitEvent : true; emitEvent = isPresent(emitEvent) ? emitEvent : true;
@ -237,10 +237,11 @@ export class Control extends AbstractControl {
* via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
* specified. * specified.
*/ */
updateValue(value: any, updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}: {
{onlySelf, emitEvent, emitModelToViewChange}: onlySelf?: boolean,
{onlySelf?: boolean, emitEvent?: boolean, emitModelToViewChange?: boolean} = {}): emitEvent?: boolean,
void { emitModelToViewChange?: boolean
} = {}): void {
emitModelToViewChange = isPresent(emitModelToViewChange) ? emitModelToViewChange : true; emitModelToViewChange = isPresent(emitModelToViewChange) ? emitModelToViewChange : true;
this._value = value; this._value = value;
if (isPresent(this._onChange) && emitModelToViewChange) this._onChange(this._value); if (isPresent(this._onChange) && emitModelToViewChange) this._onChange(this._value);

View File

@ -232,8 +232,8 @@ export abstract class DynamicComponentLoader {
* <child-component>Child</child-component> * <child-component>Child</child-component>
* ``` * ```
*/ */
abstract loadNextToLocation(type: Type, location: ElementRef, providers?: ResolvedProvider[]): abstract loadNextToLocation(type: Type, location: ElementRef,
Promise<ComponentRef>; providers?: ResolvedProvider[]): Promise<ComponentRef>;
} }
@Injectable() @Injectable()

View File

@ -283,9 +283,9 @@ function provideDirective(directiveResolver: DirectiveResolver, type: Type): Dir
return DirectiveProvider.createFromType(type, annotation); return DirectiveProvider.createFromType(type, annotation);
} }
export function createDirectiveVariableBindings(variableNameAndValues: Array<string | number>, export function createDirectiveVariableBindings(
directiveProviders: DirectiveProvider[]): variableNameAndValues: Array<string | number>,
Map<string, number> { directiveProviders: DirectiveProvider[]): Map<string, number> {
var directiveVariableBindings = new Map<string, number>(); var directiveVariableBindings = new Map<string, number>();
for (var i = 0; i < variableNameAndValues.length; i += 2) { for (var i = 0; i < variableNameAndValues.length; i += 2) {
var templateName = <string>variableNameAndValues[i]; var templateName = <string>variableNameAndValues[i];

View File

@ -165,8 +165,8 @@ export class EmbeddedTemplateCmd implements TemplateCmd, IBeginElementCmd,
export function embeddedTemplate(attrNameAndValues: string[], variableNameAndValues: string[], export function embeddedTemplate(attrNameAndValues: string[], variableNameAndValues: string[],
directives: Type[], isMerged: boolean, ngContentIndex: number, directives: Type[], isMerged: boolean, ngContentIndex: number,
changeDetectorFactory: Function, children: TemplateCmd[]): changeDetectorFactory: Function,
EmbeddedTemplateCmd { children: TemplateCmd[]): EmbeddedTemplateCmd {
return new EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, directives, isMerged, return new EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, directives, isMerged,
ngContentIndex, changeDetectorFactory, children); ngContentIndex, changeDetectorFactory, children);
} }

View File

@ -55,8 +55,8 @@ export abstract class AppViewManager {
* Throws an exception if the specified `hostLocation` is not a Host Element of a Component, or if * Throws an exception if the specified `hostLocation` is not a Host Element of a Component, or if
* variable `variableName` couldn't be found in the Component View of this Component. * variable `variableName` couldn't be found in the Component View of this Component.
*/ */
abstract getNamedElementInComponentView(hostLocation: ElementRef, variableName: string): abstract getNamedElementInComponentView(hostLocation: ElementRef,
ElementRef; variableName: string): ElementRef;
/** /**
* Returns the component instance for the provided Host Element. * Returns the component instance for the provided Host Element.

View File

@ -209,8 +209,8 @@ export abstract class Renderer {
* *
* Returns an instance of {@link RenderViewWithFragments}, representing the Render View. * Returns an instance of {@link RenderViewWithFragments}, representing the Render View.
*/ */
abstract createView(protoViewRef: RenderProtoViewRef, fragmentCount: number): abstract createView(protoViewRef: RenderProtoViewRef,
RenderViewWithFragments; fragmentCount: number): RenderViewWithFragments;
/** /**
* Destroys a Render View specified via `viewRef`. * Destroys a Render View specified via `viewRef`.

View File

@ -131,8 +131,8 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>
abstract createRootHostView(hostProtoViewRef: RenderProtoViewRef, fragmentCount: number, abstract createRootHostView(hostProtoViewRef: RenderProtoViewRef, fragmentCount: number,
hostElementSelector: string): RenderViewWithFragments; hostElementSelector: string): RenderViewWithFragments;
abstract createView(protoViewRef: RenderProtoViewRef, fragmentCount: number): abstract createView(protoViewRef: RenderProtoViewRef,
RenderViewWithFragments; fragmentCount: number): RenderViewWithFragments;
abstract destroyView(viewRef: RenderViewRef); abstract destroyView(viewRef: RenderViewRef);
@ -207,8 +207,8 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>
propertyValue); propertyValue);
} }
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string): setElementAttribute(location: RenderElementRef, attributeName: string,
void { attributeValue: string): void {
var view = resolveInternalDomView(location.renderView); var view = resolveInternalDomView(location.renderView);
var element = view.boundElements[location.boundElementIndex]; var element = view.boundElements[location.boundElementIndex];
var dashCasedAttributeName = camelCaseToDashCase(attributeName); var dashCasedAttributeName = camelCaseToDashCase(attributeName);

View File

@ -28,15 +28,15 @@ export class BrowserGetTestability implements GetTestability {
static init() { setTestabilityGetter(new BrowserGetTestability()); } static init() { setTestabilityGetter(new BrowserGetTestability()); }
addToWindow(registry: TestabilityRegistry): void { addToWindow(registry: TestabilityRegistry): void {
global.getAngularTestability = function(elem: Element, findInAncestors: boolean = true): global.getAngularTestability = function(elem: Element,
PublicTestability { findInAncestors: boolean = true): PublicTestability {
var testability = registry.findTestabilityInTree(elem, findInAncestors); var testability = registry.findTestabilityInTree(elem, findInAncestors);
if (testability == null) { if (testability == null) {
throw new Error('Could not find testability for element.'); throw new Error('Could not find testability for element.');
} }
return new PublicTestability(testability); return new PublicTestability(testability);
}; };
global.getAllAngularTestabilities = function(): PublicTestability[] { global.getAllAngularTestabilities = function(): PublicTestability[] {
var testabilities = registry.getAllTestabilities(); var testabilities = registry.getAllTestabilities();
return testabilities.map((testability) => { return new PublicTestability(testability); }); return testabilities.map((testability) => { return new PublicTestability(testability); });

View File

@ -236,8 +236,8 @@ if (!(Reflect && Reflect.getMetadata)) {
throw 'reflect-metadata shim is required when using class decorators'; throw 'reflect-metadata shim is required when using class decorators';
} }
export function makeDecorator(annotationCls, chainFn: (fn: Function) => void = null): export function makeDecorator(
(...args: any[]) => (cls: any) => any { annotationCls, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {
function DecoratorFactory(objOrType): (cls: any) => any { function DecoratorFactory(objOrType): (cls: any) => any {
var annotationInstance = new (<any>annotationCls)(objOrType); var annotationInstance = new (<any>annotationCls)(objOrType);
if (this instanceof annotationCls) { if (this instanceof annotationCls) {

View File

@ -6,7 +6,7 @@ import {Connection, ConnectionBackend} from '../interfaces';
import {isPresent} from 'angular2/src/core/facade/lang'; import {isPresent} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions'; import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
var Rx = require('@reactivex/rxjs/dist/cjs/Rx'); var Rx = require('@reactivex/rxjs/dist/cjs/Rx');
let{Subject, ReplaySubject} = Rx; let {Subject, ReplaySubject} = Rx;
/** /**
* *

View File

@ -42,6 +42,6 @@ export {
* *
* {@example router/ts/can_activate/can_activate_example.ts region='canActivate' } * {@example router/ts/can_activate/can_activate_example.ts region='canActivate' }
*/ */
export var CanActivate: export var CanActivate: (hook: (next: ComponentInstruction, prev: ComponentInstruction) =>
(hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) => Promise<boolean>| boolean) => ClassDecorator =
ClassDecorator = makeDecorator(CanActivateAnnotation); makeDecorator(CanActivateAnnotation);

View File

@ -41,8 +41,8 @@ export class Route implements RouteDefinition {
// added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107 // added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107
loader: Function; loader: Function;
redirectTo: string; redirectTo: string;
constructor({path, component, as, data}: constructor({path, component, as,
{path: string, component: Type, as?: string, data?: {[key: string]: any}}) { data}: {path: string, component: Type, as?: string, data?: {[key: string]: any}}) {
this.path = path; this.path = path;
this.component = component; this.component = component;
this.as = as; this.as = as;
@ -115,8 +115,8 @@ export class AsyncRoute implements RouteDefinition {
path: string; path: string;
loader: Function; loader: Function;
as: string; as: string;
constructor({path, loader, as, data}: constructor({path, loader, as,
{path: string, loader: Function, as?: string, data?: {[key: string]: any}}) { data}: {path: string, loader: Function, as?: string, data?: {[key: string]: any}}) {
this.path = path; this.path = path;
this.loader = loader; this.loader = loader;
this.as = as; this.as = as;

View File

@ -544,8 +544,8 @@ function splitAndFlattenLinkParams(linkParams: any[]): any[] {
}, []); }, []);
} }
function canActivateOne(nextInstruction: Instruction, prevInstruction: Instruction): function canActivateOne(nextInstruction: Instruction,
Promise<boolean> { prevInstruction: Instruction): Promise<boolean> {
var next = _resolveToTrue; var next = _resolveToTrue;
if (isPresent(nextInstruction.child)) { if (isPresent(nextInstruction.child)) {
next = canActivateOne(nextInstruction.child, next = canActivateOne(nextInstruction.child,

View File

@ -144,22 +144,22 @@ export function beforeEach(fn: FunctionWithParamTokens | AnyTestFn): void {
} }
} }
export function it(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null): export function it(name: string, fn: FunctionWithParamTokens | AnyTestFn,
void { timeOut: number = null): void {
return _it(jsmIt, name, fn, timeOut); return _it(jsmIt, name, fn, timeOut);
} }
export function xit(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null): export function xit(name: string, fn: FunctionWithParamTokens | AnyTestFn,
void { timeOut: number = null): void {
return _it(jsmXIt, name, fn, timeOut); return _it(jsmXIt, name, fn, timeOut);
} }
export function iit(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null): export function iit(name: string, fn: FunctionWithParamTokens | AnyTestFn,
void { timeOut: number = null): void {
return _it(jsmIIt, name, fn, timeOut); return _it(jsmIIt, name, fn, timeOut);
} }
export function fit(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null): export function fit(name: string, fn: FunctionWithParamTokens | AnyTestFn,
void { timeOut: number = null): void {
return _it(jsmIIt, name, fn, timeOut); return _it(jsmIIt, name, fn, timeOut);
} }

View File

@ -28,8 +28,8 @@ var _postMessage: PostMessageInterface = <any>postMessage;
* See the bootstrap() docs for more details. * See the bootstrap() docs for more details.
*/ */
export function bootstrapWebWorker( export function bootstrapWebWorker(
appComponentType: Type, componentInjectableProviders: Array<Type | Provider | any[]> = null): appComponentType: Type,
Promise<ComponentRef> { componentInjectableProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
Parse5DomAdapter.makeCurrent(); Parse5DomAdapter.makeCurrent();
var sink = new PostMessageBusSink({ var sink = new PostMessageBusSink({
postMessage: (message: any, transferrables?:[ArrayBuffer]) => { postMessage: (message: any, transferrables?:[ArrayBuffer]) => {

View File

@ -91,8 +91,8 @@ class PrintLogger {
logGroupEnd() {} logGroupEnd() {}
} }
function webWorkerProviders(appComponentType, bus: MessageBus, initData: {[key: string]: any}): function webWorkerProviders(appComponentType, bus: MessageBus,
Array<Type | Provider | any[]> { initData: {[key: string]: any}): Array<Type | Provider | any[]> {
return [ return [
compilerProviders(), compilerProviders(),
Serializer, Serializer,
@ -114,9 +114,9 @@ function webWorkerProviders(appComponentType, bus: MessageBus, initData: {[key:
]; ];
} }
export function bootstrapWebWorkerCommon(appComponentType: Type, bus: MessageBus, export function bootstrapWebWorkerCommon(
appProviders: Array<Type | Provider | any[]> = null): appComponentType: Type, bus: MessageBus,
Promise<ComponentRef> { appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
var bootstrapProcess: PromiseCompleter<any> = PromiseWrapper.completer(); var bootstrapProcess: PromiseCompleter<any> = PromiseWrapper.completer();
var appPromise = platform().asyncApplication((zone: NgZone) => { var appPromise = platform().asyncApplication((zone: NgZone) => {
// TODO(rado): prepopulate template cache, so applications with only // TODO(rado): prepopulate template cache, so applications with only

View File

@ -1,6 +1,6 @@
// no deserialization is necessary in TS. // no deserialization is necessary in TS.
// This is only here to match dart interface // This is only here to match dart interface
export function deserializeGenericEvent(serializedEvent: {[key: string]: any}): export function deserializeGenericEvent(
{[key: string]: any} { serializedEvent: {[key: string]: any}): {[key: string]: any} {
return serializedEvent; return serializedEvent;
} }

View File

@ -39,8 +39,8 @@ function _createEventRecords(expression: string): BindingRecord[] {
return [BindingRecord.createForEvent(ast, eventName, 0)]; return [BindingRecord.createForEvent(ast, eventName, 0)];
} }
function _createHostEventRecords(expression: string, directiveRecord: DirectiveRecord): function _createHostEventRecords(expression: string,
BindingRecord[] { directiveRecord: DirectiveRecord): BindingRecord[] {
var parts = expression.split("="); var parts = expression.split("=");
var eventName = parts[0].substring(1, parts[0].length - 1); var eventName = parts[0].substring(1, parts[0].length - 1);
var exp = parts[1].substring(1, parts[1].length - 1); var exp = parts[1].substring(1, parts[1].length - 1);
@ -315,48 +315,46 @@ class _DirectiveUpdating {
* Map from test id to _DirectiveUpdating. * Map from test id to _DirectiveUpdating.
* Definitions in this map define definitions which allow testing directive updating. * Definitions in this map define definitions which allow testing directive updating.
*/ */
static availableDefinitions: static availableDefinitions: {[key: string]: _DirectiveUpdating} = {
{[key: string]: _DirectiveUpdating} = { 'directNoDispatcher': new _DirectiveUpdating(
'directNoDispatcher': new _DirectiveUpdating( [_DirectiveUpdating.updateA('42', _DirectiveUpdating.basicRecords[0])],
[_DirectiveUpdating.updateA('42', _DirectiveUpdating.basicRecords[0])], [_DirectiveUpdating.basicRecords[0]]),
'groupChanges':
new _DirectiveUpdating(
[
_DirectiveUpdating.updateA('1', _DirectiveUpdating.basicRecords[0]),
_DirectiveUpdating.updateB('2', _DirectiveUpdating.basicRecords[0]),
BindingRecord.createDirectiveOnChanges(_DirectiveUpdating.basicRecords[0]),
_DirectiveUpdating.updateA('3', _DirectiveUpdating.basicRecords[1]),
BindingRecord.createDirectiveOnChanges(_DirectiveUpdating.basicRecords[1])
],
[_DirectiveUpdating.basicRecords[0], _DirectiveUpdating.basicRecords[1]]),
'directiveDoCheck': new _DirectiveUpdating(
[BindingRecord.createDirectiveDoCheck(_DirectiveUpdating.basicRecords[0])],
[_DirectiveUpdating.basicRecords[0]]),
'directiveOnInit': new _DirectiveUpdating(
[BindingRecord.createDirectiveOnInit(_DirectiveUpdating.basicRecords[0])],
[_DirectiveUpdating.basicRecords[0]]),
'emptyWithDirectiveRecords': new _DirectiveUpdating(
[], [_DirectiveUpdating.basicRecords[0], _DirectiveUpdating.basicRecords[1]]),
'noCallbacks': new _DirectiveUpdating(
[_DirectiveUpdating.updateA('1', _DirectiveUpdating.recordNoCallbacks)],
[_DirectiveUpdating.recordNoCallbacks]),
'readingDirectives':
new _DirectiveUpdating(
[
BindingRecord.createForHostProperty(
new DirectiveIndex(0, 0), _getParser().parseBinding('a', 'location'), PROP_NAME)
],
[_DirectiveUpdating.basicRecords[0]]), [_DirectiveUpdating.basicRecords[0]]),
'groupChanges': 'interpolation':
new _DirectiveUpdating( new _DirectiveUpdating(
[ [
_DirectiveUpdating.updateA('1', _DirectiveUpdating.basicRecords[0]), BindingRecord.createForElementProperty(
_DirectiveUpdating.updateB('2', _DirectiveUpdating.basicRecords[0]), _getParser().parseInterpolation('B{{a}}A', 'location'), 0, PROP_NAME)
BindingRecord.createDirectiveOnChanges(_DirectiveUpdating.basicRecords[0]), ],
_DirectiveUpdating.updateA('3', _DirectiveUpdating.basicRecords[1]), [])
BindingRecord.createDirectiveOnChanges(_DirectiveUpdating.basicRecords[1]) };
],
[_DirectiveUpdating.basicRecords[0], _DirectiveUpdating.basicRecords[1]]),
'directiveDoCheck': new _DirectiveUpdating(
[BindingRecord.createDirectiveDoCheck(_DirectiveUpdating.basicRecords[0])],
[_DirectiveUpdating.basicRecords[0]]),
'directiveOnInit': new _DirectiveUpdating(
[BindingRecord.createDirectiveOnInit(_DirectiveUpdating.basicRecords[0])],
[_DirectiveUpdating.basicRecords[0]]),
'emptyWithDirectiveRecords': new _DirectiveUpdating(
[], [_DirectiveUpdating.basicRecords[0], _DirectiveUpdating.basicRecords[1]]),
'noCallbacks': new _DirectiveUpdating(
[_DirectiveUpdating.updateA('1', _DirectiveUpdating.recordNoCallbacks)],
[_DirectiveUpdating.recordNoCallbacks]),
'readingDirectives':
new _DirectiveUpdating(
[
BindingRecord.createForHostProperty(new DirectiveIndex(0, 0),
_getParser().parseBinding('a', 'location'),
PROP_NAME)
],
[_DirectiveUpdating.basicRecords[0]]),
'interpolation':
new _DirectiveUpdating(
[
BindingRecord.createForElementProperty(
_getParser().parseInterpolation('B{{a}}A', 'location'), 0, PROP_NAME)
],
[])
};
} }
/** /**

View File

@ -13,15 +13,15 @@ import {isBlank} from 'angular2/src/core/facade/lang';
import {RecordType, ProtoRecord} from 'angular2/src/core/change_detection/proto_record'; import {RecordType, ProtoRecord} from 'angular2/src/core/change_detection/proto_record';
export function main() { export function main() {
function r({lastInBinding, mode, name, directiveIndex, argumentToPureFunction, referencedBySelf}: function r(
{ {lastInBinding, mode, name, directiveIndex, argumentToPureFunction, referencedBySelf}: {
lastInBinding?: any, lastInBinding?: any,
mode?: any, mode?: any,
name?: any, name?: any,
directiveIndex?: any, directiveIndex?: any,
argumentToPureFunction?: boolean, argumentToPureFunction?: boolean,
referencedBySelf?: boolean referencedBySelf?: boolean
} = {}) { } = {}) {
if (isBlank(lastInBinding)) lastInBinding = false; if (isBlank(lastInBinding)) lastInBinding = false;
if (isBlank(mode)) mode = RecordType.PropertyRead; if (isBlank(mode)) mode = RecordType.PropertyRead;
if (isBlank(name)) name = "name"; if (isBlank(name)) name = "name";

View File

@ -108,9 +108,9 @@ export function main() {
}); });
describe('compileComponentCodeGen', () => { describe('compileComponentCodeGen', () => {
function detectChanges(compiler: ChangeDetectionCompiler, template: string, function detectChanges(
directives: CompileDirectiveMetadata[] = CONST_EXPR([])): compiler: ChangeDetectionCompiler, template: string,
Promise<string[]> { directives: CompileDirectiveMetadata[] = CONST_EXPR([])): Promise<string[]> {
var type = var type =
new CompileTypeMetadata({name: stringify(SomeComponent), moduleUrl: THIS_MODULE_URL}); new CompileTypeMetadata({name: stringify(SomeComponent), moduleUrl: THIS_MODULE_URL});
var parsedTemplate = parser.parse(template, directives, 'TestComp'); var parsedTemplate = parser.parse(template, directives, 'TestComp');
@ -133,8 +133,8 @@ export function main() {
}); });
} }
function createTestableModule(source: SourceExpressions, changeDetectorIndex: number): function createTestableModule(source: SourceExpressions,
SourceModule { changeDetectorIndex: number): SourceModule {
var resultExpression = var resultExpression =
`${THIS_MODULE_REF}testChangeDetector(([${source.expressions.join(',')}])[${changeDetectorIndex}])`; `${THIS_MODULE_REF}testChangeDetector(([${source.expressions.join(',')}])[${changeDetectorIndex}])`;
var testableSource = `${source.declarations.join('\n')} var testableSource = `${source.declarations.join('\n')}

View File

@ -120,8 +120,8 @@ export function main() {
}); });
} }
function createDirective(type: CompileTypeMetadata, selector: string, exportAs: string = null): function createDirective(type: CompileTypeMetadata, selector: string,
CompileDirectiveMetadata { exportAs: string = null): CompileDirectiveMetadata {
return CompileDirectiveMetadata.create( return CompileDirectiveMetadata.create(
{selector: selector, exportAs: exportAs, isComponent: false, type: type}); {selector: selector, exportAs: exportAs, isComponent: false, type: type});
} }

View File

@ -42,7 +42,8 @@ export function main() {
selector: 'someSelector', selector: 'someSelector',
isComponent: true, isComponent: true,
dynamicLoadable: true, dynamicLoadable: true,
type: fullTypeMeta, template: fullTemplateMeta, type: fullTypeMeta,
template: fullTemplateMeta,
changeDetection: ChangeDetectionStrategy.Default, changeDetection: ChangeDetectionStrategy.Default,
inputs: ['someProp'], inputs: ['someProp'],
outputs: ['someEvent'], outputs: ['someEvent'],

View File

@ -74,8 +74,8 @@ export function main() {
`a {color: green}@import ${IMPORT_REL_STYLESHEET_URL};`; `a {color: green}@import ${IMPORT_REL_STYLESHEET_URL};`;
}); });
function compile(styles: string[], styleAbsUrls: string[], encapsulation: ViewEncapsulation): function compile(styles: string[], styleAbsUrls: string[],
Promise<string[]> { encapsulation: ViewEncapsulation): Promise<string[]> {
// Note: Can't use MockXHR as the xhr is called recursively, // Note: Can't use MockXHR as the xhr is called recursively,
// so we can't trigger flush. // so we can't trigger flush.
xhr.spy('get').andCallFake((url) => { xhr.spy('get').andCallFake((url) => {
@ -203,8 +203,8 @@ export function main() {
}); });
describe('compileComponentCodeGen', () => { describe('compileComponentCodeGen', () => {
function compile(styles: string[], styleAbsUrls: string[], encapsulation: ViewEncapsulation): function compile(styles: string[], styleAbsUrls: string[],
Promise<string[]> { encapsulation: ViewEncapsulation): Promise<string[]> {
var sourceExpression = compiler.compileComponentCodeGen( var sourceExpression = compiler.compileComponentCodeGen(
`'${appId}'`, `${templateId}`, `'${appId}'`, `${templateId}`,
new CompileTemplateMetadata( new CompileTemplateMetadata(

View File

@ -190,8 +190,8 @@ export function main() {
}); });
describe('compileTemplatesCodeGen', () => { describe('compileTemplatesCodeGen', () => {
function normalizeComponent(component: Type): function normalizeComponent(
Promise<NormalizedComponentWithViewDirectives> { component: Type): Promise<NormalizedComponentWithViewDirectives> {
var compAndViewDirMetas = [runtimeMetadataResolver.getMetadata(component)].concat( var compAndViewDirMetas = [runtimeMetadataResolver.getMetadata(component)].concat(
runtimeMetadataResolver.getViewDirectivesMetadata(component)); runtimeMetadataResolver.getViewDirectivesMetadata(component));
return PromiseWrapper.all(compAndViewDirMetas.map( return PromiseWrapper.all(compAndViewDirMetas.map(
@ -316,8 +316,8 @@ class CompWithEmbeddedTemplate {
class NonComponent { class NonComponent {
} }
function testableTemplateModule(sourceModule: SourceModule, normComp: CompileDirectiveMetadata): function testableTemplateModule(sourceModule: SourceModule,
SourceModule { normComp: CompileDirectiveMetadata): SourceModule {
var resultExpression = var resultExpression =
`${THIS_MODULE_REF}humanizeTemplate(Host${normComp.type.name}Template.getTemplate())`; `${THIS_MODULE_REF}humanizeTemplate(Host${normComp.type.name}Template.getTemplate())`;
var testableSource = `${sourceModule.sourceWithModuleRefs} var testableSource = `${sourceModule.sourceWithModuleRefs}
@ -332,9 +332,9 @@ function testableStylesModule(sourceModule: SourceModule): SourceModule {
} }
// Attention: read by eval! // Attention: read by eval!
export function humanizeTemplate(template: CompiledTemplate, export function humanizeTemplate(
humanizedTemplates: Map<number, {[key: string]: any}> = null): template: CompiledTemplate,
{[key: string]: any} { humanizedTemplates: Map<number, {[key: string]: any}> = null): {[key: string]: any} {
if (isBlank(humanizedTemplates)) { if (isBlank(humanizedTemplates)) {
humanizedTemplates = new Map<number, {[key: string]: any}>(); humanizedTemplates = new Map<number, {[key: string]: any}>();
} }

View File

@ -553,7 +553,8 @@ There is no directive with "exportAs" set to "dirA" at TestComp > div:nth-child(
selector: '[a]', selector: '[a]',
isComponent: true, isComponent: true,
type: new CompileTypeMetadata({name: 'DirA'}), type: new CompileTypeMetadata({name: 'DirA'}),
exportAs: 'dirA', template: new CompileTemplateMetadata({ngContentSelectors: []}) exportAs: 'dirA',
template: new CompileTemplateMetadata({ngContentSelectors: []})
}); });
expect(humanizeTemplateAsts(parse('<div a #a></div>', [dirA]))) expect(humanizeTemplateAsts(parse('<div a #a></div>', [dirA])))
.toEqual([ .toEqual([
@ -686,8 +687,8 @@ There is no directive with "exportAs" set to "dirA" at TestComp > div:nth-child(
}); });
describe('content projection', () => { describe('content projection', () => {
function createComp(selector: string, ngContentSelectors: string[]): function createComp(selector: string,
CompileDirectiveMetadata { ngContentSelectors: string[]): CompileDirectiveMetadata {
return CompileDirectiveMetadata.create({ return CompileDirectiveMetadata.create({
selector: selector, selector: selector,
isComponent: true, isComponent: true,

View File

@ -52,7 +52,7 @@ class MessageDir {
<span class="childnested" message="nestedchild">Child</span> <span class="childnested" message="nestedchild">Child</span>
</div> </div>
<span class="child" [inner-html]="childBinding"></span>`, <span class="child" [inner-html]="childBinding"></span>`,
directives: [MessageDir] directives: [MessageDir],
}) })
@Injectable() @Injectable()
class ChildComp { class ChildComp {
@ -64,7 +64,7 @@ class ChildComp {
@Component({selector: 'cond-content-comp', viewProviders: [Logger]}) @Component({selector: 'cond-content-comp', viewProviders: [Logger]})
@View({ @View({
template: `<div class="child" message="child" *ng-if="false"><ng-content></ng-content></div>`, template: `<div class="child" message="child" *ng-if="false"><ng-content></ng-content></div>`,
directives: [NgIf, MessageDir] directives: [NgIf, MessageDir],
}) })
@Injectable() @Injectable()
class ConditionalContentComp { class ConditionalContentComp {
@ -78,7 +78,7 @@ class ConditionalContentComp {
<span class="parent" [inner-html]="parentBinding"></span> <span class="parent" [inner-html]="parentBinding"></span>
<child-comp class="child-comp-class"></child-comp> <child-comp class="child-comp-class"></child-comp>
<cond-content-comp class="cond-content-comp-class"></cond-content-comp>`, <cond-content-comp class="cond-content-comp-class"></cond-content-comp>`,
directives: [ChildComp, MessageDir, ConditionalContentComp] directives: [ChildComp, MessageDir, ConditionalContentComp],
}) })
@Injectable() @Injectable()
class ParentComp { class ParentComp {
@ -98,7 +98,7 @@ class CustomEmitter {
@View({ @View({
template: `<button (click)="handleClick()"></button> template: `<button (click)="handleClick()"></button>
<custom-emitter (myevent)="handleCustom()"></custom-emitter>`, <custom-emitter (myevent)="handleCustom()"></custom-emitter>`,
directives: [CustomEmitter] directives: [CustomEmitter],
}) })
@Injectable() @Injectable()
class EventsComp { class EventsComp {
@ -121,7 +121,7 @@ class EventsComp {
<ul message="list"> <ul message="list">
<li *ng-for="#item of stuff" [inner-html]="item"></li> <li *ng-for="#item of stuff" [inner-html]="item"></li>
</ul>`, </ul>`,
directives: [NgFor, MessageDir] directives: [NgFor, MessageDir],
}) })
@Injectable() @Injectable()
class UsingFor { class UsingFor {

View File

@ -78,27 +78,29 @@ export function main() {
})); }));
it("should emit ng-submit event on submit", it("should emit ng-submit event on submit",
inject( inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
[TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => { var t = `<div>
var t = <form [ng-form-model]="form" (ng-submit)="name='updated'"></form>
`<div><form [ng-form-model]="form" (ng-submit)="name='updated'"></form><span>{{name}}</span></div>`; <span>{{name}}</span>
</div>`;
var rootTC: RootTestComponent; var rootTC: RootTestComponent;
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { rootTC = root; }); tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
tick(); (root) => { rootTC = root; });
tick();
rootTC.debugElement.componentInstance.form = new ControlGroup({}); rootTC.debugElement.componentInstance.form = new ControlGroup({});
rootTC.debugElement.componentInstance.name = 'old'; rootTC.debugElement.componentInstance.name = 'old';
tick(); tick();
var form = rootTC.debugElement.query(By.css("form")); var form = rootTC.debugElement.query(By.css("form"));
dispatchEvent(form.nativeElement, "submit"); dispatchEvent(form.nativeElement, "submit");
tick(); tick();
expect(rootTC.debugElement.componentInstance.name).toEqual('updated'); expect(rootTC.debugElement.componentInstance.name).toEqual('updated');
}))); })));
it("should work with single controls", it("should work with single controls",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {

View File

@ -43,7 +43,7 @@ export function main() {
@Component({selector: 'app', viewProviders: [forwardRef(() => Frame)]}) @Component({selector: 'app', viewProviders: [forwardRef(() => Frame)]})
@View({ @View({
template: `<door><lock></lock></door>`, template: `<door><lock></lock></door>`,
directives: [forwardRef(() => Door), forwardRef(() => Lock)] directives: [forwardRef(() => Door), forwardRef(() => Lock)],
}) })
class App { class App {
} }
@ -51,7 +51,7 @@ class App {
@Component({selector: 'Lock'}) @Component({selector: 'Lock'})
@View({ @View({
directives: [NgFor], directives: [NgFor],
template: `{{frame.name}}(<span *ng-for="var lock of locks">{{lock.name}}</span>)` template: `{{frame.name}}(<span *ng-for="var lock of locks">{{lock.name}}</span>)`,
}) })
class Door { class Door {
locks: QueryList<Lock>; locks: QueryList<Lock>;

View File

@ -2321,7 +2321,8 @@ class DirectiveThrowingAnError {
@Component({ @Component({
selector: 'component-with-template', selector: 'component-with-template',
directives: [NgFor], template: `No View Decorator: <div *ng-for="#item of items">{{item}}</div>` directives: [NgFor],
template: `No View Decorator: <div *ng-for="#item of items">{{item}}</div>`
}) })
class ComponentWithTemplate { class ComponentWithTemplate {
items = [1, 2, 3]; items = [1, 2, 3];

View File

@ -470,32 +470,32 @@ export function main() {
it('should allow to switch the order of nested components via ng-content', it('should allow to switch the order of nested components via ng-content',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView( tcb.overrideView(MainComp, new ViewMetadata({
MainComp, template: `<cmp-a><cmp-b></cmp-b></cmp-a>`,
new ViewMetadata( directives: [CmpA, CmpB],
{template: `<cmp-a><cmp-b></cmp-b></cmp-a>`, directives: [CmpA, CmpB]})) }))
.createAsync(MainComp) .createAsync(MainComp)
.then((main) => { .then((main) => {
main.detectChanges(); main.detectChanges();
expect(DOM.getInnerHTML(main.debugElement.nativeElement)) expect(DOM.getInnerHTML(main.debugElement.nativeElement))
.toEqual( .toEqual('<cmp-a><cmp-b><cmp-d><d>cmp-d</d></cmp-d></cmp-b>' +
'<cmp-a><cmp-b><cmp-d><d>cmp-d</d></cmp-d></cmp-b><cmp-c><c>cmp-c</c></cmp-c></cmp-a>'); '<cmp-c><c>cmp-c</c></cmp-c></cmp-a>');
async.done(); async.done();
}); });
})); }));
it('should create nested components in the right order', it('should create nested components in the right order',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView( tcb.overrideView(MainComp, new ViewMetadata({
MainComp, template: `<cmp-a1></cmp-a1><cmp-a2></cmp-a2>`,
new ViewMetadata( directives: [CmpA1, CmpA2],
{template: `<cmp-a1></cmp-a1><cmp-a2></cmp-a2>`, directives: [CmpA1, CmpA2]})) }))
.createAsync(MainComp) .createAsync(MainComp)
.then((main) => { .then((main) => {
main.detectChanges(); main.detectChanges();
expect(DOM.getInnerHTML(main.debugElement.nativeElement)) expect(DOM.getInnerHTML(main.debugElement.nativeElement))
.toEqual( .toEqual('<cmp-a1>a1<cmp-b11>b11</cmp-b11><cmp-b12>b12</cmp-b12></cmp-a1>' +
'<cmp-a1>a1<cmp-b11>b11</cmp-b11><cmp-b12>b12</cmp-b12></cmp-a1><cmp-a2>a2<cmp-b21>b21</cmp-b21><cmp-b22>b22</cmp-b22></cmp-a2>'); '<cmp-a2>a2<cmp-b21>b21</cmp-b21><cmp-b22>b22</cmp-b22></cmp-a2>');
async.done(); async.done();
}); });
})); }));

View File

@ -31,7 +31,7 @@ import {
} from 'angular2/http'; } from 'angular2/http';
var Rx = require('@reactivex/rxjs/dist/cjs/Rx'); var Rx = require('@reactivex/rxjs/dist/cjs/Rx');
let{Observable, Subject} = Rx; let {Observable, Subject} = Rx;
class SpyObserver extends SpyObject { class SpyObserver extends SpyObject {
onNext: Function; onNext: Function;

View File

@ -288,16 +288,24 @@ function parentLoader() {
} }
@Component({selector: 'parent-cmp'}) @Component({selector: 'parent-cmp'})
@View({template: "inner { <router-outlet></router-outlet> }", directives: [RouterOutlet]}) @View({
@RouteConfig( template: "inner { <router-outlet></router-outlet> }",
[new Route({path: '/b', component: HelloCmp}), new Route({path: '/', component: HelloCmp})]) directives: [RouterOutlet],
})
@RouteConfig([
new Route({path: '/b', component: HelloCmp}),
new Route({path: '/', component: HelloCmp}),
])
class ParentCmp { class ParentCmp {
constructor() {} constructor() {}
} }
@Component({selector: 'team-cmp'}) @Component({selector: 'team-cmp'})
@View({template: "team {{id}} { <router-outlet></router-outlet> }", directives: [RouterOutlet]}) @View({
template: "team {{id}} { <router-outlet></router-outlet> }",
directives: [RouterOutlet],
})
@RouteConfig([new Route({path: '/user/:name', component: UserCmp})]) @RouteConfig([new Route({path: '/user/:name', component: UserCmp})])
class TeamCmp { class TeamCmp {
id: string; id: string;
@ -320,13 +328,13 @@ class ModalCmp {
@Component({selector: 'aux-cmp'}) @Component({selector: 'aux-cmp'})
@View({ @View({
template: template: 'main {<router-outlet></router-outlet>} | ' +
`main {<router-outlet></router-outlet>} | aux {<router-outlet name="modal"></router-outlet>}`, 'aux {<router-outlet name="modal"></router-outlet>}',
directives: [RouterOutlet] directives: [RouterOutlet],
}) })
@RouteConfig([ @RouteConfig([
new Route({path: '/hello', component: HelloCmp}), new Route({path: '/hello', component: HelloCmp}),
new AuxRoute({path: '/modal', component: ModalCmp}) new AuxRoute({path: '/modal', component: ModalCmp}),
]) ])
class AuxCmp { class AuxCmp {
} }

View File

@ -235,8 +235,7 @@ class StaticTreeComponent0 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent0], directives: [StaticTreeComponent0],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent1 extends StaticTreeComponentBase { class StaticTreeComponent1 extends StaticTreeComponentBase {
} }
@ -244,8 +243,7 @@ class StaticTreeComponent1 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent1], directives: [StaticTreeComponent1],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent2 extends StaticTreeComponentBase { class StaticTreeComponent2 extends StaticTreeComponentBase {
data: TreeNode; data: TreeNode;
@ -254,8 +252,7 @@ class StaticTreeComponent2 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent2], directives: [StaticTreeComponent2],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent3 extends StaticTreeComponentBase { class StaticTreeComponent3 extends StaticTreeComponentBase {
} }
@ -263,8 +260,7 @@ class StaticTreeComponent3 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent3], directives: [StaticTreeComponent3],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent4 extends StaticTreeComponentBase { class StaticTreeComponent4 extends StaticTreeComponentBase {
} }
@ -272,8 +268,7 @@ class StaticTreeComponent4 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent4], directives: [StaticTreeComponent4],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent5 extends StaticTreeComponentBase { class StaticTreeComponent5 extends StaticTreeComponentBase {
} }
@ -281,8 +276,7 @@ class StaticTreeComponent5 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent5], directives: [StaticTreeComponent5],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent6 extends StaticTreeComponentBase { class StaticTreeComponent6 extends StaticTreeComponentBase {
} }
@ -290,8 +284,7 @@ class StaticTreeComponent6 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent6], directives: [StaticTreeComponent6],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent7 extends StaticTreeComponentBase { class StaticTreeComponent7 extends StaticTreeComponentBase {
} }
@ -299,8 +292,7 @@ class StaticTreeComponent7 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent7], directives: [StaticTreeComponent7],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent8 extends StaticTreeComponentBase { class StaticTreeComponent8 extends StaticTreeComponentBase {
} }
@ -308,8 +300,7 @@ class StaticTreeComponent8 extends StaticTreeComponentBase {
@Component({selector: 'tree', inputs: ['data']}) @Component({selector: 'tree', inputs: ['data']})
@View({ @View({
directives: [StaticTreeComponent8], directives: [StaticTreeComponent8],
template: template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
}) })
class StaticTreeComponent9 extends StaticTreeComponentBase { class StaticTreeComponent9 extends StaticTreeComponentBase {
} }

View File

@ -13,8 +13,7 @@ function addTreeDirective(module, level: number) {
if (level <= 0) { if (level <= 0) {
template = `<span> {{data.value}}</span>` template = `<span> {{data.value}}</span>`
} else { } else {
template = template = `<span> {{data.value}} <tree${level-1} data='data.right'></tree${level-1}><tree${level-1} data='data.left'></tree${level-1}></span>`;
`<span> {{data.value}} <tree${level-1} data='data.right'></tree${level-1}><tree${level-1} data='data.left'></tree${level-1}></span>`;
} }
module.directive(`tree${level}`, function() { return {scope: {data: '='}, template: template}; }); module.directive(`tree${level}`, function() { return {scope: {data: '='}, template: template}; });
} }

View File

@ -220,8 +220,8 @@ export class ChromeDriverExtension extends WebDriverExtension {
} }
} }
function normalizeEvent(chromeEvent: {[key: string]: any}, data: {[key: string]: any}): function normalizeEvent(chromeEvent: {[key: string]: any},
{[key: string]: any} { data: {[key: string]: any}): {[key: string]: any} {
var ph = chromeEvent['ph']; var ph = chromeEvent['ph'];
if (StringWrapper.equals(ph, 'S')) { if (StringWrapper.equals(ph, 'S')) {
ph = 'b'; ph = 'b';

View File

@ -372,7 +372,8 @@ export function main() {
var ng1 = function() { var ng1 = function() {
return { return {
scope: {title: '@'}, scope: {title: '@'},
bindToController: true, template: '{{ctl.title}}', bindToController: true,
template: '{{ctl.title}}',
controllerAs: 'ctl', controllerAs: 'ctl',
controller: Class({constructor: function() {}}) controller: Class({constructor: function() {}})
}; };
@ -400,7 +401,8 @@ export function main() {
var ng1 = function($rootScope) { var ng1 = function($rootScope) {
return { return {
scope: {title: '@'}, scope: {title: '@'},
bindToController: true, template: '{{ctl.status}}', bindToController: true,
template: '{{ctl.status}}',
require: 'ng1', require: 'ng1',
controller: Class({constructor: function() { this.status = 'WORKS'; }}), controller: Class({constructor: function() { this.status = 'WORKS'; }}),
link: function(scope, element, attrs, linkController) { link: function(scope, element, attrs, linkController) {
@ -437,7 +439,8 @@ export function main() {
var ng1 = function() { var ng1 = function() {
return { return {
scope: {title: '@'}, scope: {title: '@'},
bindToController: true, template: '{{parent.parent}}:{{ng1.status}}', bindToController: true,
template: '{{parent.parent}}:{{ng1.status}}',
require: ['ng1', '^parent', '?^^notFound'], require: ['ng1', '^parent', '?^^notFound'],
controller: Class({constructor: function() { this.status = 'WORKS'; }}), controller: Class({constructor: function() { this.status = 'WORKS'; }}),
link: function(scope, element, attrs, linkControllers) { link: function(scope, element, attrs, linkControllers) {
@ -510,7 +513,8 @@ export function main() {
module.directive('ng1', function() { module.directive('ng1', function() {
return { return {
scope: {title: '='}, scope: {title: '='},
transclude: true, template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)' transclude: true,
template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'
}; };
}); });

View File

@ -27,7 +27,7 @@ export class LodashRenderer implements DiffingBroccoliPlugin {
private options: LodashRendererOptions = kDefaultOptions) {} private options: LodashRendererOptions = kDefaultOptions) {}
rebuild(treeDiff: DiffResult) { rebuild(treeDiff: DiffResult) {
let{encoding = 'utf-8', context = {}} = this.options; let {encoding = 'utf-8', context = {}} = this.options;
let processFile = (relativePath) => { let processFile = (relativePath) => {
let sourceFilePath = path.join(this.inputPath, relativePath); let sourceFilePath = path.join(this.inputPath, relativePath);
let destFilePath = path.join(this.cachePath, relativePath); let destFilePath = path.join(this.cachePath, relativePath);

View File

@ -124,7 +124,7 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
allDiagnostics.forEach(diagnostic => { allDiagnostics.forEach(diagnostic => {
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
if (diagnostic.file) { if (diagnostic.file) {
let{line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); let {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
errors.push(` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); errors.push(` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
} else { } else {
errors.push(` Error: ${message}`); errors.push(` Error: ${message}`);