Skip to content

Commit d310a9c

Browse files
committed
chore: rename if to ng-if
1 parent 7dc524e commit d310a9c

File tree

13 files changed

+56
-56
lines changed

13 files changed

+56
-56
lines changed

modules/angular2/directives.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import {CONST_EXPR} from './src/facade/lang';
99
import {For} from './src/directives/for';
10-
import {If} from './src/directives/if';
10+
import {NgIf} from './src/directives/ng_if';
1111
import {NonBindable} from './src/directives/non_bindable';
1212
import {Switch, SwitchWhen, SwitchDefault} from './src/directives/switch';
1313

1414
export * from './src/directives/class';
1515
export * from './src/directives/for';
16-
export * from './src/directives/if';
16+
export * from './src/directives/ng_if';
1717
export * from './src/directives/non_bindable';
1818
export * from './src/directives/switch';
1919

@@ -58,5 +58,5 @@ export * from './src/directives/switch';
5858
*
5959
*/
6060
export const coreDirectives:List = CONST_EXPR([
61-
For, If, NonBindable, Switch, SwitchWhen, SwitchDefault
61+
For, NgIf, NonBindable, Switch, SwitchWhen, SwitchDefault
6262
]);

modules/angular2/src/directives/if.js renamed to modules/angular2/src/directives/ng_if.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ import {isBlank} from 'angular2/src/facade/lang';
1212
* # Example:
1313
*
1414
* ```
15-
* <div *if="errorCount > 0" class="error">
15+
* <div *ng-if="errorCount > 0" class="error">
1616
* <!-- Error message displayed when the errorCount property on the current context is greater than 0. -->
1717
* {{errorCount}} errors detected
1818
* </div>
1919
* ```
2020
*
2121
* # Syntax
2222
*
23-
* - `<div *if="condition">...</div>`
24-
* - `<div template="if condition">...</div>`
25-
* - `<template [if]="condition"><div>...</div></template>`
23+
* - `<div *ng-if="condition">...</div>`
24+
* - `<div template="ng-if condition">...</div>`
25+
* - `<template [ng-if]="condition"><div>...</div></template>`
2626
*
2727
* @exportedAs angular2/directives
2828
*/
2929
@Directive({
30-
selector: '[if]',
30+
selector: '[ng-if]',
3131
properties: {
32-
'condition': 'if'
32+
'ngIf': 'ngIf'
3333
}
3434
})
35-
export class If {
35+
export class NgIf {
3636
viewContainer: ViewContainerRef;
3737
protoViewRef: ProtoViewRef;
3838
prevCondition: boolean;
@@ -43,7 +43,7 @@ export class If {
4343
this.protoViewRef = protoViewRef;
4444
}
4545

46-
set condition(newCondition /* boolean */) {
46+
set ngIf(newCondition /* boolean */) {
4747
if (newCondition && (isBlank(this.prevCondition) || !this.prevCondition)) {
4848
this.prevCondition = true;
4949
this.viewContainer.create(this.protoViewRef);

modules/angular2/src/render/dom/compiler/view_splitter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ViewSplitter extends CompileStep {
3838
var templateBindings = MapWrapper.get(attrs, 'template');
3939
var hasTemplateBinding = isPresent(templateBindings);
4040

41-
// look for template shortcuts such as *if="condition" and treat them as template="if condition"
41+
// look for template shortcuts such as *ng-if="condition" and treat them as template="if condition"
4242
MapWrapper.forEach(attrs, (attrValue, attrName) => {
4343
if (StringWrapper.startsWith(attrName, '*')) {
4444
var key = StringWrapper.substring(attrName, 1); // remove the star

modules/angular2/test/core/compiler/dynamic_component_loader_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {Component} from 'angular2/src/core/annotations_impl/annotations';
2020
import {View} from 'angular2/src/core/annotations_impl/view';
2121
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
2222
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
23-
import {If} from 'angular2/src/directives/if';
23+
import {NgIf} from 'angular2/src/directives/ng_if';
2424
import {DomRenderer} from 'angular2/src/render/dom/dom_renderer';
2525
import {DOM} from 'angular2/src/dom/dom_adapter';
2626
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
@@ -64,8 +64,8 @@ export function main() {
6464
it('should allow to destroy and create them via viewcontainer directives',
6565
inject([TestBed, AsyncTestCompleter], (tb, async) => {
6666
tb.overrideView(MyComp, new View({
67-
template: '<div><dynamic-comp #dynamic template="if: ctxBoolProp"></dynamic-comp></div>',
68-
directives: [DynamicComp, If]
67+
template: '<div><dynamic-comp #dynamic template="ng-if: ctxBoolProp"></dynamic-comp></div>',
68+
directives: [DynamicComp, NgIf]
6969
}));
7070

7171
tb.createView(MyComp).then((view) => {

modules/angular2/test/core/compiler/integration_spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {View} from 'angular2/src/core/annotations_impl/view';
3232
import {Parent, Ancestor} from 'angular2/src/core/annotations_impl/visibility';
3333
import {Attribute, Query} from 'angular2/src/core/annotations_impl/di';
3434

35-
import {If} from 'angular2/src/directives/if';
35+
import {NgIf} from 'angular2/src/directives/ng_if';
3636
import {For} from 'angular2/src/directives/for';
3737

3838
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
@@ -561,11 +561,11 @@ export function main() {
561561
tb.overrideView(MyComp, new View({
562562
template: `
563563
<some-directive>
564-
<p *if="true">
564+
<p *ng-if="true">
565565
<cmp-with-ancestor #child></cmp-with-ancestor>
566566
</p>
567567
</some-directive>`,
568-
directives: [SomeDirective, CompWithAncestor, If]
568+
directives: [SomeDirective, CompWithAncestor, NgIf]
569569
}));
570570

571571
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -728,8 +728,8 @@ export function main() {
728728

729729
it('should support render global events from multiple directives', inject([TestBed, AsyncTestCompleter], (tb, async) => {
730730
tb.overrideView(MyComp, new View({
731-
template: '<div *if="ctxBoolProp" listener listenerother></div>',
732-
directives: [If, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
731+
template: '<div *ng-if="ctxBoolProp" listener listenerother></div>',
732+
directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
733733
}));
734734

735735
tb.createView(MyComp, {context: ctx}).then((view) => {
@@ -894,17 +894,17 @@ export function main() {
894894
it('should raise an error for missing template directive (2)', inject([TestBed, AsyncTestCompleter], (tb, async) => {
895895
expectCompileError(
896896
tb,
897-
'<div><template *if="condition"></template></div>',
898-
'Missing directive to handle: <template *if="condition">',
897+
'<div><template *ng-if="condition"></template></div>',
898+
'Missing directive to handle: <template *ng-if="condition">',
899899
() => async.done()
900900
);
901901
}));
902902

903903
it('should raise an error for missing template directive (3)', inject([TestBed, AsyncTestCompleter], (tb, async) => {
904904
expectCompileError(
905905
tb,
906-
'<div *if="condition"></div>',
907-
'Missing directive to handle \'if\' in MyComp: <div *if="condition">',
906+
'<div *ng-if="condition"></div>',
907+
'Missing directive to handle \'if\' in MyComp: <div *ng-if="condition">',
908908
() => async.done()
909909
);
910910
}));

modules/angular2/test/core/compiler/query_integration_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
1717
import {QueryList} from 'angular2/src/core/compiler/query_list';
1818
import {Query} from 'angular2/src/core/annotations_impl/di';
1919

20-
import {If, For} from 'angular2/angular2';
20+
import {NgIf, For} from 'angular2/angular2';
2121

2222
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
2323
import {View} from 'angular2/src/core/annotations_impl/view';
@@ -45,7 +45,7 @@ export function main() {
4545
it('should reflect dynamically inserted directives', inject([TestBed, AsyncTestCompleter], (tb, async) => {
4646
var template =
4747
'<div text="1"></div>' +
48-
'<needs-query text="2"><div *if="shouldShow" [text]="\'3\'"></div></needs-query>' +
48+
'<needs-query text="2"><div *ng-if="shouldShow" [text]="\'3\'"></div></needs-query>' +
4949
'<div text="4"></div>';
5050

5151
tb.createView(MyComp, {html: template}).then((view) => {
@@ -113,7 +113,7 @@ class TextDirective {
113113

114114
@Component({selector: 'my-comp'})
115115
@View({
116-
directives: [NeedsQuery, TextDirective, If, For]
116+
directives: [NeedsQuery, TextDirective, NgIf, For]
117117
})
118118
class MyComp {
119119
shouldShow: boolean;

modules/angular2/test/directives/if_spec.js renamed to modules/angular2/test/directives/ng_if_spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
1919
import {Component} from 'angular2/src/core/annotations_impl/annotations';
2020
import {View} from 'angular2/src/core/annotations_impl/view';
2121

22-
import {If} from 'angular2/src/directives/if';
22+
import {NgIf} from 'angular2/src/directives/ng_if';
2323

2424
export function main() {
2525
describe('if directive', () => {
2626
it('should work in a template attribute', inject([TestBed, AsyncTestCompleter], (tb, async) => {
27-
var html = '<div><copy-me template="if booleanCondition">hello</copy-me></div>';
27+
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
2828

2929
tb.createView(TestComponent, {html: html}).then((view) => {
3030
view.detectChanges();
@@ -35,7 +35,7 @@ export function main() {
3535
}));
3636

3737
it('should work in a template element', inject([TestBed, AsyncTestCompleter], (tb, async) => {
38-
var html = '<div><template [if]="booleanCondition"><copy-me>hello2</copy-me></template></div>';
38+
var html = '<div><template [ng-if]="booleanCondition"><copy-me>hello2</copy-me></template></div>';
3939

4040
tb.createView(TestComponent, {html: html}).then((view) => {
4141
view.detectChanges();
@@ -46,7 +46,7 @@ export function main() {
4646
}));
4747

4848
it('should toggle node when condition changes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
49-
var html = '<div><copy-me template="if booleanCondition">hello</copy-me></div>';
49+
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
5050

5151
tb.createView(TestComponent, {html: html}).then((view) => {
5252
view.context.booleanCondition = false;
@@ -69,7 +69,7 @@ export function main() {
6969
}));
7070

7171
it('should handle nested if correctly', inject([TestBed, AsyncTestCompleter], (tb, async) => {
72-
var html = '<div><template [if]="booleanCondition"><copy-me *if="nestedBooleanCondition">hello</copy-me></template></div>';
72+
var html = '<div><template [ng-if]="booleanCondition"><copy-me *ng-if="nestedBooleanCondition">hello</copy-me></template></div>';
7373

7474
tb.createView(TestComponent, {html: html}).then((view) => {
7575
view.context.booleanCondition = false;
@@ -104,9 +104,9 @@ export function main() {
104104
it('should update several nodes with if', inject([TestBed, AsyncTestCompleter], (tb, async) => {
105105
var html =
106106
'<div>' +
107-
'<copy-me template="if numberCondition + 1 >= 2">helloNumber</copy-me>' +
108-
'<copy-me template="if stringCondition == \'foo\'">helloString</copy-me>' +
109-
'<copy-me template="if functionCondition(stringCondition, numberCondition)">helloFunction</copy-me>' +
107+
'<copy-me template="ng-if numberCondition + 1 >= 2">helloNumber</copy-me>' +
108+
'<copy-me template="ng-if stringCondition == \'foo\'">helloString</copy-me>' +
109+
'<copy-me template="ng-if functionCondition(stringCondition, numberCondition)">helloFunction</copy-me>' +
110110
'</div>';
111111

112112
tb.createView(TestComponent, {html: html}).then((view) => {
@@ -132,7 +132,7 @@ export function main() {
132132
if (!IS_DARTIUM) {
133133
it('should not add the element twice if the condition goes from true to true (JS)',
134134
inject([TestBed, AsyncTestCompleter], (tb, async) => {
135-
var html = '<div><copy-me template="if numberCondition">hello</copy-me></div>';
135+
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
136136

137137
tb.createView(TestComponent, {html: html}).then((view) => {
138138
view.detectChanges();
@@ -150,7 +150,7 @@ export function main() {
150150

151151
it('should not recreate the element if the condition goes from true to true (JS)',
152152
inject([TestBed, AsyncTestCompleter], (tb, async) => {
153-
var html = '<div><copy-me template="if numberCondition">hello</copy-me></div>';
153+
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
154154

155155
tb.createView(TestComponent, {html: html}).then((view) => {
156156
view.detectChanges();
@@ -168,7 +168,7 @@ export function main() {
168168
if (IS_DARTIUM) {
169169
it('should not create the element if the condition is not a boolean (DART)',
170170
inject([TestBed, AsyncTestCompleter], (tb, async) => {
171-
var html = '<div><copy-me template="if numberCondition">hello</copy-me></div>';
171+
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
172172

173173
tb.createView(TestComponent, {html: html}).then((view) => {
174174
expect(() => view.detectChanges()).toThrowError();
@@ -183,7 +183,7 @@ export function main() {
183183
}
184184

185185
@Component({selector: 'test-cmp'})
186-
@View({directives: [If]})
186+
@View({directives: [NgIf]})
187187
class TestComponent {
188188
booleanCondition: boolean;
189189
nestedBooleanCondition: boolean;

modules/angular2/test/render/dom/compiler/view_splitter_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ export function main() {
144144
describe('elements with *directive_name attribute', () => {
145145

146146
it('should replace the element with an empty <template> element', () => {
147-
var rootElement = el('<div><span *if></span></div>');
147+
var rootElement = el('<div><span *ng-if></span></div>');
148148
var originalChild = rootElement.childNodes[0];
149149
var results = createPipeline().process(rootElement);
150150
expect(results[0].element).toBe(rootElement);
151-
expect(DOM.getOuterHTML(results[0].element)).toEqual('<div><template class="ng-binding" if=""></template></div>');
152-
expect(DOM.getOuterHTML(results[2].element)).toEqual('<span *if=""></span>')
151+
expect(DOM.getOuterHTML(results[0].element)).toEqual('<div><template class="ng-binding" ng-if=""></template></div>');
152+
expect(DOM.getOuterHTML(results[2].element)).toEqual('<span *ng-if=""></span>')
153153
expect(results[2].element).toBe(originalChild);
154154
});
155155

modules/benchmarks/src/costs/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ export function main() {
5656
@View({
5757
directives: [If, For, DummyComponent, DummyDirective, DynamicDummy],
5858
template: `
59-
<div *if="testingPlainComponents">
59+
<div *ng-if="testingPlainComponents">
6060
<dummy *for="#i of list"></dummy>
6161
</div>
6262
63-
<div *if="testingWithDirectives">
63+
<div *ng-if="testingWithDirectives">
6464
<dummy dummy-decorator *for="#i of list"></dummy>
6565
</div>
6666
67-
<div *if="testingDynamicComponents">
67+
<div *ng-if="testingDynamicComponents">
6868
<dynamic-dummy *for="#i of list"></dynamic-dummy>
6969
</div>
7070
`

modules/benchmarks/src/naive_infinite_scroll/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util'
33
import {PromiseWrapper} from 'angular2/src/facade/async';
44
import {ListWrapper} from 'angular2/src/facade/collection';
55
import {ScrollAreaComponent} from './scroll_area';
6-
import {If, For} from 'angular2/directives';
6+
import {NgIf, For} from 'angular2/directives';
77
import {DOM} from 'angular2/src/dom/dom_adapter';
88
import {document} from 'angular2/src/facade/browser';
99

@@ -14,7 +14,7 @@ import {View} from 'angular2/src/core/annotations_impl/view';
1414

1515
@Component({selector: 'scroll-app'})
1616
@View({
17-
directives: [ScrollAreaComponent, If, For],
17+
directives: [ScrollAreaComponent, NgIf, For],
1818
template: `
1919
<div>
2020
<div style="display: flex">

0 commit comments

Comments
 (0)