From f543834be956e5543cf60df4ce7ab5cf8bce2ba9 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Tue, 2 Jun 2015 14:53:49 -0700 Subject: [PATCH] feat(forms): renamed control, control-group into ng-control and ng-control-group --- .../directives/checkbox_value_accessor.ts | 4 +- .../src/forms/directives/control_directive.ts | 2 +- .../directives/control_group_directive.ts | 18 ++-- .../directives/control_name_directive.ts | 8 +- .../directives/default_value_accessor.ts | 7 +- .../directives/form_control_directive.ts | 6 +- .../forms/directives/form_model_directive.ts | 10 +-- .../forms/directives/ng_model_directive.ts | 2 +- .../select_control_value_accessor.ts | 4 +- .../template_driven_form_directive.ts | 2 +- .../angular2/test/forms/integration_spec.ts | 83 ++++++++++--------- 11 files changed, 73 insertions(+), 73 deletions(-) diff --git a/modules/angular2/src/forms/directives/checkbox_value_accessor.ts b/modules/angular2/src/forms/directives/checkbox_value_accessor.ts index 6a97cd235a..dfd020198e 100644 --- a/modules/angular2/src/forms/directives/checkbox_value_accessor.ts +++ b/modules/angular2/src/forms/directives/checkbox_value_accessor.ts @@ -9,14 +9,14 @@ import {ControlValueAccessor} from './control_value_accessor'; * * # Example * ``` - * + * * ``` * * @exportedAs angular2/forms */ @Directive({ selector: - 'input[type=checkbox][control],input[type=checkbox][form-control],input[type=checkbox][ng-model]', + 'input[type=checkbox][ng-control],input[type=checkbox][ng-form-control],input[type=checkbox][ng-model]', hostListeners: {'change': 'onChange($event.target.checked)'}, hostProperties: {'checked': 'checked'} }) diff --git a/modules/angular2/src/forms/directives/control_directive.ts b/modules/angular2/src/forms/directives/control_directive.ts index 97aa4caab2..dbd9478d19 100644 --- a/modules/angular2/src/forms/directives/control_directive.ts +++ b/modules/angular2/src/forms/directives/control_directive.ts @@ -2,7 +2,7 @@ import {ControlValueAccessor} from './control_value_accessor'; import {Validators} from '../validators'; /** - * A directive that bind a [Control] object to a DOM element. + * A directive that bind a [ng-control] object to a DOM element. * * @exportedAs angular2/forms */ diff --git a/modules/angular2/src/forms/directives/control_group_directive.ts b/modules/angular2/src/forms/directives/control_group_directive.ts index 99cf549d4c..b9a9d3bc5b 100644 --- a/modules/angular2/src/forms/directives/control_group_directive.ts +++ b/modules/angular2/src/forms/directives/control_group_directive.ts @@ -10,11 +10,11 @@ const controlGroupBinding = CONST_EXPR( new Binding(ControlContainerDirective, {toAlias: FORWARD_REF(() => ControlGroupDirective)})); /** - * Binds a control group to a DOM element. + * Binds a ng-control group to a DOM element. * * # Example * - * In this example, we create a control group, and we bind the login and + * In this example, we create a ng-control group, and we bind the login and * password controls to the login and password elements. * * Here we use {@link formDirectives}, rather than importing each form directive individually, e.g. @@ -25,10 +25,10 @@ const controlGroupBinding = CONST_EXPR( * @View({ * directives: [formDirectives], * template: - * "
" + - * "
- * "Login " + - * "Password " + + * "" + + * "
+ * "Login " + + * "Password " + * "" + * "
" * "" @@ -39,7 +39,7 @@ const controlGroupBinding = CONST_EXPR( * constructor() { * this.loginForm = new ControlGroup({ * credentials: new ControlGroup({ - * login: new Control(""), + * login: new Cntrol(""), * password: new Control("") * }) * }); @@ -55,9 +55,9 @@ const controlGroupBinding = CONST_EXPR( * @exportedAs angular2/forms */ @Directive({ - selector: '[control-group]', + selector: '[ng-control-group]', hostInjector: [controlGroupBinding], - properties: ['name: control-group'], + properties: ['name: ng-control-group'], lifecycle: [onInit, onDestroy] }) export class ControlGroupDirective extends ControlContainerDirective { diff --git a/modules/angular2/src/forms/directives/control_name_directive.ts b/modules/angular2/src/forms/directives/control_name_directive.ts index d6868b5421..4f16fadcce 100644 --- a/modules/angular2/src/forms/directives/control_name_directive.ts +++ b/modules/angular2/src/forms/directives/control_name_directive.ts @@ -31,8 +31,8 @@ const controlNameBinding = * @View({ * directives: [formDirectives], * template: - * "
" + - * "Login " + + * "" + + * "Login " + * "" + * "
" * }) @@ -55,9 +55,9 @@ const controlNameBinding = * @exportedAs angular2/forms */ @Directive({ - selector: '[control]', + selector: '[ng-control]', hostInjector: [controlNameBinding], - properties: ['name: control', 'model: ng-model'], + properties: ['name: ng-control', 'model: ng-model'], events: ['ngModel'], lifecycle: [onDestroy, onChange] }) diff --git a/modules/angular2/src/forms/directives/default_value_accessor.ts b/modules/angular2/src/forms/directives/default_value_accessor.ts index 30dba86228..0922b069df 100644 --- a/modules/angular2/src/forms/directives/default_value_accessor.ts +++ b/modules/angular2/src/forms/directives/default_value_accessor.ts @@ -11,15 +11,14 @@ import {ControlValueAccessor} from './control_value_accessor'; * * # Example * ``` - * + * * ``` * * @exportedAs angular2/forms */ @Directive({ - selector: 'input:not([type=checkbox])[control],textarea[control],' + - 'input:not([type=checkbox])[form-control],textarea[form-control],' + - 'input:not([type=checkbox])[ng-model],textarea[ng-model]', + selector: + 'input:not([type=checkbox])[ng-control],textarea[ng-control],input:not([type=checkbox])[ng-form-control],textarea[ng-form-control],input:not([type=checkbox])[ng-model],textarea[ng-model]', hostListeners: {'change': 'onChange($event.target.value)', 'input': 'onChange($event.target.value)'}, hostProperties: {'value': 'value'} diff --git a/modules/angular2/src/forms/directives/form_control_directive.ts b/modules/angular2/src/forms/directives/form_control_directive.ts index 208ef0d5a1..ebfcd599a0 100644 --- a/modules/angular2/src/forms/directives/form_control_directive.ts +++ b/modules/angular2/src/forms/directives/form_control_directive.ts @@ -30,7 +30,7 @@ const formControlBinding = * @Component({selector: "login-comp"}) * @View({ * directives: [formDirectives], - * template: "" + * template: "" * }) * class LoginComp { * loginControl:Control; @@ -45,9 +45,9 @@ const formControlBinding = * @exportedAs angular2/forms */ @Directive({ - selector: '[form-control]', + selector: '[ng-form-control]', hostInjector: [formControlBinding], - properties: ['control: form-control', 'model: ng-model'], + properties: ['control: ng-form-control', 'model: ng-model'], events: ['ngModel'], lifecycle: [onChange] }) diff --git a/modules/angular2/src/forms/directives/form_model_directive.ts b/modules/angular2/src/forms/directives/form_model_directive.ts index ce6816294b..651209779e 100644 --- a/modules/angular2/src/forms/directives/form_model_directive.ts +++ b/modules/angular2/src/forms/directives/form_model_directive.ts @@ -28,9 +28,9 @@ const formDirectiveBinding = CONST_EXPR( * @Component({selector: "login-comp"}) * @View({ * directives: [formDirectives], - * template: "
" + - * "Login " + - * "Password " + + * template: "" + + * "Login " + + * "Password " + * "" + * "
" * }) @@ -54,9 +54,9 @@ const formDirectiveBinding = CONST_EXPR( * @exportedAs angular2/forms */ @Directive({ - selector: '[form-model]', + selector: '[ng-form-model]', hostInjector: [formDirectiveBinding], - properties: ['form: form-model'], + properties: ['form: ng-form-model'], lifecycle: [onChange] }) export class FormModelDirective extends ControlContainerDirective implements FormDirective { diff --git a/modules/angular2/src/forms/directives/ng_model_directive.ts b/modules/angular2/src/forms/directives/ng_model_directive.ts index c6b9036ba0..9b5cbaa8ee 100644 --- a/modules/angular2/src/forms/directives/ng_model_directive.ts +++ b/modules/angular2/src/forms/directives/ng_model_directive.ts @@ -13,7 +13,7 @@ const formControlBinding = CONST_EXPR(new Binding(ControlDirective, {toAlias: FORWARD_REF(() => NgModelDirective)})); @Directive({ - selector: '[ng-model]:not([control]):not([form-control])', + selector: '[ng-model]:not([ng-control]):not([ng-form-control])', hostInjector: [formControlBinding], properties: ['model: ng-model'], events: ['ngModel'], diff --git a/modules/angular2/src/forms/directives/select_control_value_accessor.ts b/modules/angular2/src/forms/directives/select_control_value_accessor.ts index 0275721187..5a4889226e 100644 --- a/modules/angular2/src/forms/directives/select_control_value_accessor.ts +++ b/modules/angular2/src/forms/directives/select_control_value_accessor.ts @@ -11,13 +11,13 @@ import {ControlValueAccessor} from './control_value_accessor'; * * # Example * ``` - * + * * ``` * * @exportedAs angular2/forms */ @Directive({ - selector: 'select[control],select[form-control],select[ng-model]', + selector: 'select[ng-control],select[ng-form-control],select[ng-model]', hostListeners: {'change': 'onChange($event.target.value)', 'input': 'onChange($event.target.value)'}, hostProperties: {'value': 'value'} diff --git a/modules/angular2/src/forms/directives/template_driven_form_directive.ts b/modules/angular2/src/forms/directives/template_driven_form_directive.ts index fb39da64cb..a13fe54372 100644 --- a/modules/angular2/src/forms/directives/template_driven_form_directive.ts +++ b/modules/angular2/src/forms/directives/template_driven_form_directive.ts @@ -14,7 +14,7 @@ const formDirectiveBinding = CONST_EXPR(new Binding( ControlContainerDirective, {toAlias: FORWARD_REF(() => TemplateDrivenFormDirective)})); @Directive({ - selector: 'form:not([ng-no-form]):not([form-model]),ng-form,[ng-form]', + selector: 'form:not([ng-no-form]):not([ng-form-model]),ng-form,[ng-form]', hostInjector: [formDirectiveBinding] }) export class TemplateDrivenFormDirective extends ControlContainerDirective implements diff --git a/modules/angular2/test/forms/integration_spec.ts b/modules/angular2/test/forms/integration_spec.ts index bee7092718..44f4c02297 100644 --- a/modules/angular2/test/forms/integration_spec.ts +++ b/modules/angular2/test/forms/integration_spec.ts @@ -37,8 +37,8 @@ export function main() { inject([TestBed, AsyncTestCompleter], (tb, async) => { var ctx = MyComp.create({form: new ControlGroup({"login": new Control("loginValue")})}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -56,8 +56,8 @@ export function main() { var form = new ControlGroup({"login": new Control("oldValue")}); var ctx = MyComp.create({form: form}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -77,7 +77,7 @@ export function main() { var control = new Control("loginValue"); var ctx = MyComp.create({form: control}); - var t = `
`; + var t = `
`; tb.createView(MyComp, {context: ctx, html: t}) .then((view) => { @@ -98,8 +98,8 @@ export function main() { var form = new ControlGroup({"login": new Control("oldValue")}); var ctx = MyComp.create({form: form}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -120,8 +120,8 @@ export function main() { var form = new ControlGroup({"login": login}); var ctx = MyComp.create({form: form}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -142,8 +142,8 @@ export function main() { it("should support ", inject([TestBed, AsyncTestCompleter], (tb, async) => { var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -164,8 +164,8 @@ export function main() { inject([TestBed, AsyncTestCompleter], (tb, async) => { var ctx = MyComp.create({form: new ControlGroup({"text": new Control("old")})}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -185,8 +185,8 @@ export function main() { it("should support + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -206,8 +206,8 @@ export function main() { it("should support ", inject([TestBed, AsyncTestCompleter], (tb, async) => { var ctx = MyComp.create({form: new ControlGroup({"checkbox": new Control(true)})}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -227,8 +227,8 @@ export function main() { it("should support + var t = `
+ @@ -255,8 +255,8 @@ export function main() { inject([TestBed, AsyncTestCompleter], (tb, async) => { var ctx = MyComp.create({form: new ControlGroup({"name": new Control("aa")})}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -280,8 +280,8 @@ export function main() { var form = new ControlGroup({"login": new Control("aa")}); var ctx = MyComp.create({form: form}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -304,8 +304,8 @@ export function main() { var form = new ControlGroup({"login": new Control("aa", Validators.required)}); var ctx = MyComp.create({form: form}); - var t = `
- + var t = `
+
`; tb.createView(MyComp, {context: ctx, html: t}) @@ -331,9 +331,9 @@ export function main() { new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})}); var ctx = MyComp.create({form: form}); - var t = `
-
- + var t = `
+
+
`; @@ -352,9 +352,9 @@ export function main() { new ControlGroup({"nested": new ControlGroup({"login": new Control("value")})}); var ctx = MyComp.create({form: form}); - var t = `
-
- + var t = `
+
+
`; @@ -379,7 +379,7 @@ export function main() { var ctx = MyComp.create({name: "oldValue", form: form}); var t = - `
`; + `
`; tb.createView(MyComp, {context: ctx, html: t}) .then((view) => { @@ -403,7 +403,8 @@ export function main() { var form = new Control(""); var ctx = MyComp.create({name: "oldValue", form: form}); - var t = `
`; + var t = + `
`; tb.createView(MyComp, {context: ctx, html: t}) .then((view) => { @@ -428,8 +429,8 @@ export function main() { var ctx = MyComp.create({name: null}); var t = `
-
- +
+
`; @@ -469,7 +470,7 @@ export function main() { var t = `
- +
`; @@ -498,8 +499,8 @@ export function main() { var t = `
-
- +
+
`; @@ -526,9 +527,9 @@ export function main() { inject([TestBed], fakeAsync(tb => { var ctx = MyComp.create({name: "oldValue"}); - var t = `
- -
`; + var t = `
+ +
`; tb.createView(MyComp, {context: ctx, html: t}) .then((view) => {