From d310a9c0b466407ddce0babdf36d7e4c2476cae3 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 11 May 2015 15:58:59 -0700 Subject: [PATCH] chore: rename if to ng-if --- modules/angular2/directives.js | 6 ++--- .../src/directives/{if.js => ng_if.js} | 16 ++++++------- .../src/render/dom/compiler/view_splitter.js | 2 +- .../compiler/dynamic_component_loader_spec.js | 6 ++--- .../test/core/compiler/integration_spec.js | 18 +++++++------- .../core/compiler/query_integration_spec.js | 6 ++--- .../directives/{if_spec.js => ng_if_spec.js} | 24 +++++++++---------- .../render/dom/compiler/view_splitter_spec.js | 6 ++--- modules/benchmarks/src/costs/index.js | 6 ++--- .../src/naive_infinite_scroll/app.js | 4 ++-- .../src/naive_infinite_scroll/app.dart | 2 +- .../src/tree/tree_benchmark.dart | 4 ++-- modules/examples/src/forms/index.es6 | 12 +++++----- 13 files changed, 56 insertions(+), 56 deletions(-) rename modules/angular2/src/directives/{if.js => ng_if.js} (82%) rename modules/angular2/test/directives/{if_spec.js => ng_if_spec.js} (86%) diff --git a/modules/angular2/directives.js b/modules/angular2/directives.js index 19416a2828..b17a413e41 100644 --- a/modules/angular2/directives.js +++ b/modules/angular2/directives.js @@ -7,13 +7,13 @@ import {CONST_EXPR} from './src/facade/lang'; import {For} from './src/directives/for'; -import {If} from './src/directives/if'; +import {NgIf} from './src/directives/ng_if'; import {NonBindable} from './src/directives/non_bindable'; import {Switch, SwitchWhen, SwitchDefault} from './src/directives/switch'; export * from './src/directives/class'; export * from './src/directives/for'; -export * from './src/directives/if'; +export * from './src/directives/ng_if'; export * from './src/directives/non_bindable'; export * from './src/directives/switch'; @@ -58,5 +58,5 @@ export * from './src/directives/switch'; * */ export const coreDirectives:List = CONST_EXPR([ - For, If, NonBindable, Switch, SwitchWhen, SwitchDefault + For, NgIf, NonBindable, Switch, SwitchWhen, SwitchDefault ]); diff --git a/modules/angular2/src/directives/if.js b/modules/angular2/src/directives/ng_if.js similarity index 82% rename from modules/angular2/src/directives/if.js rename to modules/angular2/src/directives/ng_if.js index 40eb7f7c64..dcf71365de 100644 --- a/modules/angular2/src/directives/if.js +++ b/modules/angular2/src/directives/ng_if.js @@ -12,7 +12,7 @@ import {isBlank} from 'angular2/src/facade/lang'; * # Example: * * ``` - *
+ *
* * {{errorCount}} errors detected *
@@ -20,19 +20,19 @@ import {isBlank} from 'angular2/src/facade/lang'; * * # Syntax * - * - `
...
` - * - `
...
` - * - `` + * - `
...
` + * - `
...
` + * - `` * * @exportedAs angular2/directives */ @Directive({ - selector: '[if]', + selector: '[ng-if]', properties: { - 'condition': 'if' + 'ngIf': 'ngIf' } }) -export class If { +export class NgIf { viewContainer: ViewContainerRef; protoViewRef: ProtoViewRef; prevCondition: boolean; @@ -43,7 +43,7 @@ export class If { this.protoViewRef = protoViewRef; } - set condition(newCondition /* boolean */) { + set ngIf(newCondition /* boolean */) { if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) { this.prevCondition = true; this.viewContainer.create(this.protoViewRef); diff --git a/modules/angular2/src/render/dom/compiler/view_splitter.js b/modules/angular2/src/render/dom/compiler/view_splitter.js index 22dc233f67..96baa15175 100644 --- a/modules/angular2/src/render/dom/compiler/view_splitter.js +++ b/modules/angular2/src/render/dom/compiler/view_splitter.js @@ -38,7 +38,7 @@ export class ViewSplitter extends CompileStep { var templateBindings = MapWrapper.get(attrs, 'template'); var hasTemplateBinding = isPresent(templateBindings); - // look for template shortcuts such as *if="condition" and treat them as template="if condition" + // look for template shortcuts such as *ng-if="condition" and treat them as template="if condition" MapWrapper.forEach(attrs, (attrValue, attrName) => { if (StringWrapper.startsWith(attrName, '*')) { var key = StringWrapper.substring(attrName, 1); // remove the star diff --git a/modules/angular2/test/core/compiler/dynamic_component_loader_spec.js b/modules/angular2/test/core/compiler/dynamic_component_loader_spec.js index db2c6a333a..df73ec3b17 100644 --- a/modules/angular2/test/core/compiler/dynamic_component_loader_spec.js +++ b/modules/angular2/test/core/compiler/dynamic_component_loader_spec.js @@ -20,7 +20,7 @@ import {Component} from 'angular2/src/core/annotations_impl/annotations'; import {View} from 'angular2/src/core/annotations_impl/view'; import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader'; import {ElementRef} from 'angular2/src/core/compiler/element_ref'; -import {If} from 'angular2/src/directives/if'; +import {NgIf} from 'angular2/src/directives/ng_if'; import {DomRenderer} from 'angular2/src/render/dom/dom_renderer'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {AppViewManager} from 'angular2/src/core/compiler/view_manager'; @@ -64,8 +64,8 @@ export function main() { it('should allow to destroy and create them via viewcontainer directives', inject([TestBed, AsyncTestCompleter], (tb, async) => { tb.overrideView(MyComp, new View({ - template: '
', - directives: [DynamicComp, If] + template: '
', + directives: [DynamicComp, NgIf] })); tb.createView(MyComp).then((view) => { diff --git a/modules/angular2/test/core/compiler/integration_spec.js b/modules/angular2/test/core/compiler/integration_spec.js index 6fac87bbf8..994c4dd70e 100644 --- a/modules/angular2/test/core/compiler/integration_spec.js +++ b/modules/angular2/test/core/compiler/integration_spec.js @@ -32,7 +32,7 @@ import {View} from 'angular2/src/core/annotations_impl/view'; import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility'; import {Attribute, Query} from 'angular2/src/core/annotations_impl/di'; -import {If} from 'angular2/src/directives/if'; +import {NgIf} from 'angular2/src/directives/ng_if'; import {For} from 'angular2/src/directives/for'; import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref'; @@ -561,11 +561,11 @@ export function main() { tb.overrideView(MyComp, new View({ template: ` -

+

`, - directives: [SomeDirective, CompWithAncestor, If] + directives: [SomeDirective, CompWithAncestor, NgIf] })); tb.createView(MyComp, {context: ctx}).then((view) => { @@ -728,8 +728,8 @@ export function main() { it('should support render global events from multiple directives', inject([TestBed, AsyncTestCompleter], (tb, async) => { tb.overrideView(MyComp, new View({ - template: '
', - directives: [If, DirectiveListeningDomEvent, DirectiveListeningDomEventOther] + template: '
', + directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther] })); tb.createView(MyComp, {context: ctx}).then((view) => { @@ -894,8 +894,8 @@ export function main() { it('should raise an error for missing template directive (2)', inject([TestBed, AsyncTestCompleter], (tb, async) => { expectCompileError( tb, - '
', - 'Missing directive to handle: