chore: rename if to ng-if
This commit is contained in:
@@ -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: '<div><dynamic-comp #dynamic template="if: ctxBoolProp"></dynamic-comp></div>',
|
||||
directives: [DynamicComp, If]
|
||||
template: '<div><dynamic-comp #dynamic template="ng-if: ctxBoolProp"></dynamic-comp></div>',
|
||||
directives: [DynamicComp, NgIf]
|
||||
}));
|
||||
|
||||
tb.createView(MyComp).then((view) => {
|
||||
|
||||
+9
-9
@@ -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: `
|
||||
<some-directive>
|
||||
<p *if="true">
|
||||
<p *ng-if="true">
|
||||
<cmp-with-ancestor #child></cmp-with-ancestor>
|
||||
</p>
|
||||
</some-directive>`,
|
||||
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: '<div *if="ctxBoolProp" listener listenerother></div>',
|
||||
directives: [If, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
|
||||
template: '<div *ng-if="ctxBoolProp" listener listenerother></div>',
|
||||
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,
|
||||
'<div><template *if="condition"></template></div>',
|
||||
'Missing directive to handle: <template *if="condition">',
|
||||
'<div><template *ng-if="condition"></template></div>',
|
||||
'Missing directive to handle: <template *ng-if="condition">',
|
||||
() => async.done()
|
||||
);
|
||||
}));
|
||||
@@ -903,8 +903,8 @@ export function main() {
|
||||
it('should raise an error for missing template directive (3)', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
expectCompileError(
|
||||
tb,
|
||||
'<div *if="condition"></div>',
|
||||
'Missing directive to handle \'if\' in MyComp: <div *if="condition">',
|
||||
'<div *ng-if="condition"></div>',
|
||||
'Missing directive to handle \'if\' in MyComp: <div *ng-if="condition">',
|
||||
() => async.done()
|
||||
);
|
||||
}));
|
||||
|
||||
@@ -17,7 +17,7 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
import {QueryList} from 'angular2/src/core/compiler/query_list';
|
||||
import {Query} from 'angular2/src/core/annotations_impl/di';
|
||||
|
||||
import {If, For} from 'angular2/angular2';
|
||||
import {NgIf, For} from 'angular2/angular2';
|
||||
|
||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
@@ -45,7 +45,7 @@ export function main() {
|
||||
it('should reflect dynamically inserted directives', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var template =
|
||||
'<div text="1"></div>' +
|
||||
'<needs-query text="2"><div *if="shouldShow" [text]="\'3\'"></div></needs-query>' +
|
||||
'<needs-query text="2"><div *ng-if="shouldShow" [text]="\'3\'"></div></needs-query>' +
|
||||
'<div text="4"></div>';
|
||||
|
||||
tb.createView(MyComp, {html: template}).then((view) => {
|
||||
@@ -113,7 +113,7 @@ class TextDirective {
|
||||
|
||||
@Component({selector: 'my-comp'})
|
||||
@View({
|
||||
directives: [NeedsQuery, TextDirective, If, For]
|
||||
directives: [NeedsQuery, TextDirective, NgIf, For]
|
||||
})
|
||||
class MyComp {
|
||||
shouldShow: boolean;
|
||||
|
||||
Vendored
+12
-12
@@ -19,12 +19,12 @@ import {TestBed} from 'angular2/src/test_lib/test_bed';
|
||||
import {Component} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
|
||||
import {If} from 'angular2/src/directives/if';
|
||||
import {NgIf} from 'angular2/src/directives/ng_if';
|
||||
|
||||
export function main() {
|
||||
describe('if directive', () => {
|
||||
it('should work in a template attribute', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><copy-me template="if booleanCondition">hello</copy-me></div>';
|
||||
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
view.detectChanges();
|
||||
@@ -35,7 +35,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should work in a template element', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><template [if]="booleanCondition"><copy-me>hello2</copy-me></template></div>';
|
||||
var html = '<div><template [ng-if]="booleanCondition"><copy-me>hello2</copy-me></template></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
view.detectChanges();
|
||||
@@ -46,7 +46,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should toggle node when condition changes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><copy-me template="if booleanCondition">hello</copy-me></div>';
|
||||
var html = '<div><copy-me template="ng-if booleanCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
view.context.booleanCondition = false;
|
||||
@@ -69,7 +69,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should handle nested if correctly', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><template [if]="booleanCondition"><copy-me *if="nestedBooleanCondition">hello</copy-me></template></div>';
|
||||
var html = '<div><template [ng-if]="booleanCondition"><copy-me *ng-if="nestedBooleanCondition">hello</copy-me></template></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
view.context.booleanCondition = false;
|
||||
@@ -104,9 +104,9 @@ export function main() {
|
||||
it('should update several nodes with if', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html =
|
||||
'<div>' +
|
||||
'<copy-me template="if numberCondition + 1 >= 2">helloNumber</copy-me>' +
|
||||
'<copy-me template="if stringCondition == \'foo\'">helloString</copy-me>' +
|
||||
'<copy-me template="if functionCondition(stringCondition, numberCondition)">helloFunction</copy-me>' +
|
||||
'<copy-me template="ng-if numberCondition + 1 >= 2">helloNumber</copy-me>' +
|
||||
'<copy-me template="ng-if stringCondition == \'foo\'">helloString</copy-me>' +
|
||||
'<copy-me template="ng-if functionCondition(stringCondition, numberCondition)">helloFunction</copy-me>' +
|
||||
'</div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
@@ -132,7 +132,7 @@ export function main() {
|
||||
if (!IS_DARTIUM) {
|
||||
it('should not add the element twice if the condition goes from true to true (JS)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><copy-me template="if numberCondition">hello</copy-me></div>';
|
||||
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
view.detectChanges();
|
||||
@@ -150,7 +150,7 @@ export function main() {
|
||||
|
||||
it('should not recreate the element if the condition goes from true to true (JS)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><copy-me template="if numberCondition">hello</copy-me></div>';
|
||||
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
view.detectChanges();
|
||||
@@ -168,7 +168,7 @@ export function main() {
|
||||
if (IS_DARTIUM) {
|
||||
it('should not create the element if the condition is not a boolean (DART)',
|
||||
inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
var html = '<div><copy-me template="if numberCondition">hello</copy-me></div>';
|
||||
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
|
||||
|
||||
tb.createView(TestComponent, {html: html}).then((view) => {
|
||||
expect(() => view.detectChanges()).toThrowError();
|
||||
@@ -183,7 +183,7 @@ export function main() {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmp'})
|
||||
@View({directives: [If]})
|
||||
@View({directives: [NgIf]})
|
||||
class TestComponent {
|
||||
booleanCondition: boolean;
|
||||
nestedBooleanCondition: boolean;
|
||||
@@ -144,12 +144,12 @@ export function main() {
|
||||
describe('elements with *directive_name attribute', () => {
|
||||
|
||||
it('should replace the element with an empty <template> element', () => {
|
||||
var rootElement = el('<div><span *if></span></div>');
|
||||
var rootElement = el('<div><span *ng-if></span></div>');
|
||||
var originalChild = rootElement.childNodes[0];
|
||||
var results = createPipeline().process(rootElement);
|
||||
expect(results[0].element).toBe(rootElement);
|
||||
expect(DOM.getOuterHTML(results[0].element)).toEqual('<div><template class="ng-binding" if=""></template></div>');
|
||||
expect(DOM.getOuterHTML(results[2].element)).toEqual('<span *if=""></span>')
|
||||
expect(DOM.getOuterHTML(results[0].element)).toEqual('<div><template class="ng-binding" ng-if=""></template></div>');
|
||||
expect(DOM.getOuterHTML(results[2].element)).toEqual('<span *ng-if=""></span>')
|
||||
expect(results[2].element).toBe(originalChild);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user