Skip to content

Commit e9f236b

Browse files
committed
chore: rename switch to ng-switch
1 parent 78d3f62 commit e9f236b

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

modules/angular2/directives.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import {CONST_EXPR} from './src/facade/lang';
99
import {For} from './src/directives/for';
1010
import {NgIf} from './src/directives/ng_if';
1111
import {NgNonBindable} from './src/directives/ng_non_bindable';
12-
import {Switch, SwitchWhen, SwitchDefault} from './src/directives/switch';
12+
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './src/directives/ng_switch';
1313

1414
export * from './src/directives/class';
1515
export * from './src/directives/for';
1616
export * from './src/directives/ng_if';
1717
export * from './src/directives/ng_non_bindable';
18-
export * from './src/directives/switch';
18+
export * from './src/directives/ng_switch';
1919

2020
/**
2121
* A collection of the Angular core directives that are likely to be used in each and every Angular application.
@@ -24,15 +24,15 @@ export * from './src/directives/switch';
2424
* instead of writing:
2525
*
2626
* ```
27-
* import {If, For, Switch, SwitchWhen, SwitchDefault} from 'angular2/angular2';
27+
* import {If, For, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/angular2';
2828
* import {OtherDirective} from 'myDirectives';
2929
*
3030
* @Component({
3131
* selector: 'my-component'
3232
* })
3333
* @View({
3434
* templateUrl: 'myComponent.html',
35-
* directives: [If, For, Switch, SwitchWhen, SwitchDefault, OtherDirective]
35+
* directives: [If, For, NgSwitch, NgSwitchWhen, NgSwitchDefault, OtherDirective]
3636
* })
3737
* export class MyComponent {
3838
* ...
@@ -58,5 +58,5 @@ export * from './src/directives/switch';
5858
*
5959
*/
6060
export const coreDirectives:List = CONST_EXPR([
61-
For, NgIf, NgNonBindable, Switch, SwitchWhen, SwitchDefault
61+
For, NgIf, NgNonBindable, NgSwitch, NgSwitchWhen, NgSwitchDefault
6262
]);

modules/angular2/src/directives/switch.js renamed to modules/angular2/src/directives/ng_switch.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,39 @@ class SwitchView {
2424
}
2525

2626
/**
27-
* The `Switch` directive is used to conditionally swap DOM structure on your template based on a
27+
* The `NgSwitch` directive is used to conditionally swap DOM structure on your template based on a
2828
* scope expression.
29-
* Elements within `Switch` but without `SwitchWhen` or `SwitchDefault` directives will be
29+
* Elements within `NgSwitch` but without `NgSwitchWhen` or `NgSwitchDefault` directives will be
3030
* preserved at the location as specified in the template.
3131
*
32-
* `Switch` simply chooses nested elements and makes them visible based on which element matches
32+
* `NgSwitch` simply chooses nested elements and makes them visible based on which element matches
3333
* the value obtained from the evaluated expression. In other words, you define a container element
34-
* (where you place the directive), place an expression on the **`[switch]="..."` attribute**),
35-
* define any inner elements inside of the directive and place a `[switch-when]` attribute per
34+
* (where you place the directive), place an expression on the **`[ng-switch]="..."` attribute**),
35+
* define any inner elements inside of the directive and place a `[ng-switch-when]` attribute per
3636
* element.
37-
* The when attribute is used to inform Switch which element to display when the expression is
37+
* The when attribute is used to inform NgSwitch which element to display when the expression is
3838
* evaluated. If a matching expression is not found via a when attribute then an element with the
3939
* default attribute is displayed.
4040
*
4141
* # Example:
4242
*
4343
* ```
44-
* <ANY [switch]="expression">
45-
* <template [switch-when]="whenExpression1">...</template>
46-
* <template [switch-when]="whenExpression1">...</template>
47-
* <template [switch-default]>...</template>
44+
* <ANY [ng-switch]="expression">
45+
* <template [ng-switch-when]="whenExpression1">...</template>
46+
* <template [ng-switch-when]="whenExpression1">...</template>
47+
* <template [ng-switch-default]>...</template>
4848
* </ANY>
4949
* ```
5050
*
5151
* @exportedAs angular2/directives
5252
*/
5353
@Directive({
54-
selector: '[switch]',
54+
selector: '[ng-switch]',
5555
properties: {
56-
'value': 'switch'
56+
'ngSwitch': 'ngSwitch'
5757
}
5858
})
59-
export class Switch {
59+
export class NgSwitch {
6060
_switchValue: any;
6161
_useDefault: boolean;
6262
_valueViews: Map;
@@ -68,7 +68,7 @@ export class Switch {
6868
this._useDefault = false;
6969
}
7070

71-
set value(value) {
71+
set ngSwitch(value) {
7272
// Empty the currently active ViewContainers
7373
this._emptyAllActiveViews();
7474

@@ -150,32 +150,32 @@ export class Switch {
150150
/**
151151
* Defines a case statement as an expression.
152152
*
153-
* If multiple `SwitchWhen` match the `Switch` value, all of them are displayed.
153+
* If multiple `NgSwitchWhen` match the `NgSwitch` value, all of them are displayed.
154154
*
155155
* Example:
156156
*
157157
* ```
158158
* // match against a context variable
159-
* <template [switch-when]="contextVariable">...</template>
159+
* <template [ng-switch-when]="contextVariable">...</template>
160160
*
161161
* // match against a constant string
162-
* <template [switch-when]="'stringValue'">...</template>
162+
* <template [ng-switch-when]="'stringValue'">...</template>
163163
* ```
164164
*
165165
* @exportedAs angular2/directives
166166
*/
167167
@Directive({
168-
selector: '[switch-when]',
168+
selector: '[ng-switch-when]',
169169
properties: {
170-
'when' : 'switch-when'
170+
'ngSwitchWhen' : 'ngSwitchWhen'
171171
}
172172
})
173-
export class SwitchWhen {
173+
export class NgSwitchWhen {
174174
_value: any;
175-
_switch: Switch;
175+
_switch: NgSwitch;
176176
_view: SwitchView;
177177

178-
constructor(viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef, @Parent() sswitch: Switch) {
178+
constructor(viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef, @Parent() sswitch: NgSwitch) {
179179
// `_whenDefault` is used as a marker for a not yet initialized value
180180
this._value = _whenDefault;
181181
this._switch = sswitch;
@@ -186,7 +186,7 @@ export class SwitchWhen {
186186
this._switch
187187
}
188188

189-
set when(value) {
189+
set ngSwitchWhen(value) {
190190
this._switch._onWhenValueChanged(this._value, value, this._view);
191191
this._value = value;
192192
}
@@ -196,21 +196,21 @@ export class SwitchWhen {
196196
/**
197197
* Defines a default case statement.
198198
*
199-
* Default case statements are displayed when no `SwitchWhen` match the `switch` value.
199+
* Default case statements are displayed when no `NgSwitchWhen` match the `switch` value.
200200
*
201201
* Example:
202202
*
203203
* ```
204-
* <template [switch-default]>...</template>
204+
* <template [ng-switch-default]>...</template>
205205
* ```
206206
*
207207
* @exportedAs angular2/directives
208208
*/
209209
@Directive({
210-
selector: '[switch-default]'
210+
selector: '[ng-switch-default]'
211211
})
212-
export class SwitchDefault {
213-
constructor(viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef, @Parent() sswitch: Switch) {
212+
export class NgSwitchDefault {
213+
constructor(viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef, @Parent() sswitch: NgSwitch) {
214214
sswitch._registerView(_whenDefault, new SwitchView(viewContainer, protoViewRef));
215215
}
216216
}

modules/angular2/test/directives/switch_spec.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
1515
import {Component} from 'angular2/src/core/annotations_impl/annotations';
1616
import {View} from 'angular2/src/core/annotations_impl/view';
1717

18-
import {Switch, SwitchWhen, SwitchDefault} from 'angular2/src/directives/switch';
18+
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from '../../src/directives/ng_switch';
1919

2020
import {TestBed} from 'angular2/src/test_lib/test_bed';
2121

@@ -24,9 +24,9 @@ export function main() {
2424
describe('switch value changes', () => {
2525
it('should switch amongst when values', inject([TestBed, AsyncTestCompleter], (tb, async) => {
2626
var template = '<div>' +
27-
'<ul [switch]="switchValue">' +
28-
'<template [switch-when]="\'a\'"><li>when a</li></template>' +
29-
'<template [switch-when]="\'b\'"><li>when b</li></template>' +
27+
'<ul [ng-switch]="switchValue">' +
28+
'<template [ng-switch-when]="\'a\'"><li>when a</li></template>' +
29+
'<template [ng-switch-when]="\'b\'"><li>when b</li></template>' +
3030
'</ul></div>';
3131

3232
tb.createView(TestComponent, {html: template}).then((view) => {
@@ -48,9 +48,9 @@ export function main() {
4848
it('should switch amongst when values with fallback to default',
4949
inject([TestBed, AsyncTestCompleter], (tb, async) => {
5050
var template = '<div>' +
51-
'<ul [switch]="switchValue">' +
52-
'<li template="switch-when \'a\'">when a</li>' +
53-
'<li template="switch-default">when default</li>' +
51+
'<ul [ng-switch]="switchValue">' +
52+
'<li template="ng-switch-when \'a\'">when a</li>' +
53+
'<li template="ng-switch-default">when default</li>' +
5454
'</ul></div>';
5555

5656
tb.createView(TestComponent, {html: template}).then((view) => {
@@ -72,13 +72,13 @@ export function main() {
7272
it('should support multiple whens with the same value',
7373
inject([TestBed, AsyncTestCompleter], (tb, async) => {
7474
var template = '<div>' +
75-
'<ul [switch]="switchValue">' +
76-
'<template [switch-when]="\'a\'"><li>when a1;</li></template>' +
77-
'<template [switch-when]="\'b\'"><li>when b1;</li></template>' +
78-
'<template [switch-when]="\'a\'"><li>when a2;</li></template>' +
79-
'<template [switch-when]="\'b\'"><li>when b2;</li></template>' +
80-
'<template [switch-default]><li>when default1;</li></template>' +
81-
'<template [switch-default]><li>when default2;</li></template>' +
75+
'<ul [ng-switch]="switchValue">' +
76+
'<template [ng-switch-when]="\'a\'"><li>when a1;</li></template>' +
77+
'<template [ng-switch-when]="\'b\'"><li>when b1;</li></template>' +
78+
'<template [ng-switch-when]="\'a\'"><li>when a2;</li></template>' +
79+
'<template [ng-switch-when]="\'b\'"><li>when b2;</li></template>' +
80+
'<template [ng-switch-default]><li>when default1;</li></template>' +
81+
'<template [ng-switch-default]><li>when default2;</li></template>' +
8282
'</ul></div>';
8383

8484
tb.createView(TestComponent, {html: template}).then((view) => {
@@ -102,10 +102,10 @@ export function main() {
102102
it('should switch amongst when values',
103103
inject([TestBed, AsyncTestCompleter], (tb, async) => {
104104
var template = '<div>' +
105-
'<ul [switch]="switchValue">' +
106-
'<template [switch-when]="when1"><li>when 1;</li></template>' +
107-
'<template [switch-when]="when2"><li>when 2;</li></template>' +
108-
'<template [switch-default]><li>when default;</li></template>' +
105+
'<ul [ng-switch]="switchValue">' +
106+
'<template [ng-switch-when]="when1"><li>when 1;</li></template>' +
107+
'<template [ng-switch-when]="when2"><li>when 2;</li></template>' +
108+
'<template [ng-switch-default]><li>when default;</li></template>' +
109109
'</ul></div>';
110110

111111
tb.createView(TestComponent, {html: template}).then((view) => {
@@ -139,7 +139,7 @@ export function main() {
139139
}
140140

141141
@Component({selector: 'test-cmp'})
142-
@View({directives: [Switch, SwitchWhen, SwitchDefault]})
142+
@View({directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault]})
143143
class TestComponent {
144144
switchValue: any;
145145
when1: any;

modules/benchmarks/src/largetable/largetable_benchmark.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
1313
import {window, document, gc} from 'angular2/src/facade/browser';
1414
import {getIntParameter, getStringParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';
1515

16-
import {For, Switch, SwitchWhen, SwitchDefault} from 'angular2/directives';
16+
import {For, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/directives';
1717
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
1818

1919
import {ListWrapper} from 'angular2/src/facade/collection';
@@ -239,9 +239,9 @@ class AppComponent {
239239
}
240240
})
241241
@View({
242-
directives: [For, Switch, SwitchWhen, SwitchDefault],
242+
directives: [For, NgSwitch, NgSwitchWhen, NgSwitchDefault],
243243
template: `
244-
<table [switch]="benchmarkType">
244+
<table [ng-switch]="benchmarkType">
245245
<tbody template="switch-when 'interpolation'">
246246
<tr template="for #row of data">
247247
<td template="for #column of row">

modules/examples/src/material/switcher/demo_app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div md-theme="default">
2-
<h2>Switch demo</h2>
2+
<h2>NgSwitch demo</h2>
33

44
<md-switch (^click)="increment()">Normal switch</md-switch>
55
<md-switch class="md-primary" (^click)="increment()">Primary switch</md-switch>

0 commit comments

Comments
 (0)