GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(forms): default to unsetValue for value accessors (#846) · javaage/nativescript-angular@6940955

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • nativescript-angular/forms/value-accessors
    • base-value-accessor.ts
    • checked-value-accessor.ts
    • date-value-accessor.ts
    • number-value-accessor.ts
    • selectedIndex-value-accessor.ts
    • text-value-accessor.ts
    • time-value-accessor.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎nativescript-angular/forms/value-accessors/base-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/base-value-accessor.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ControlValueAccessor } from "@angular/forms";
2-
import { View } from "tns-core-modules/ui/core/view";
2+
import { View, unsetValue } from "tns-core-modules/ui/core/view";
3+
4+
import { isBlank } from "../../lang-facade";
35

46
export class BaseValueAccessor<TView extends View> implements ControlValueAccessor {
57
private pendingChangeNotification: any = 0;
@@ -28,5 +30,9 @@ export class BaseValueAccessor<TView extends View> implements ControlValueAccess
2830
this.view.isEnabled = !isDisabled;
2931
}
3032

31-
writeValue(_: any) { }
33+
writeValue(_: any) {}
34+
35+
protected normalizeValue(value: any): any {
36+
return isBlank(value) ? unsetValue : value;
37+
}
3238
}
Collapse file

‎nativescript-angular/forms/value-accessors/checked-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/checked-value-accessor.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class CheckedValueAccessor extends BaseValueAccessor<Switch> { // tslint:
3434
}
3535

3636
writeValue(value: any): void {
37-
this.view.checked = value;
37+
const normalized = super.normalizeValue(value);
38+
this.view.checked = normalized;
3839
}
3940
}
Collapse file

‎nativescript-angular/forms/value-accessors/date-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/date-value-accessor.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class DateValueAccessor extends BaseValueAccessor<DatePicker> { // tslint
3434
}
3535

3636
writeValue(value: any): void {
37-
this.view.date = value;
37+
const normalized = super.normalizeValue(value);
38+
this.view.date = normalized;
3839
}
3940
}
Collapse file

‎nativescript-angular/forms/value-accessors/number-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/number-value-accessor.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class NumberValueAccessor extends BaseValueAccessor<Slider> { // tslint:d
3333
}
3434

3535
writeValue(value: any): void {
36-
this.view.value = value;
36+
const normalized = super.normalizeValue(value);
37+
this.view.value = normalized;
3738
}
3839
}
Collapse file

‎nativescript-angular/forms/value-accessors/selectedIndex-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/selectedIndex-value-accessor.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export class SelectedIndexValueAccessor extends BaseValueAccessor<SelectableView
5050
private viewInitialized: boolean;
5151

5252
writeValue(value: any): void {
53-
this.value = value;
53+
const normalized = super.normalizeValue(value);
54+
this.value = normalized;
5455

5556
if (this.viewInitialized) {
5657
this.view.selectedIndex = this.value;
Collapse file

‎nativescript-angular/forms/value-accessors/text-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/text-value-accessor.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class TextValueAccessor extends BaseValueAccessor<TextView> { // tslint:d
4848
}
4949

5050
writeValue(value: any): void {
51-
this.view.text = value;
51+
const normalized = super.normalizeValue(value);
52+
this.view.text = normalized;
5253
}
5354
}
Collapse file

‎nativescript-angular/forms/value-accessors/time-value-accessor.ts‎

Copy file name to clipboardExpand all lines: nativescript-angular/forms/value-accessors/time-value-accessor.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class TimeValueAccessor extends BaseValueAccessor<TimePicker> { // tslint
3636
}
3737

3838
writeValue(value: any): void {
39-
this.view.time = value;
39+
const normalized = super.normalizeValue(value);
40+
this.view.time = normalized;
4041
}
4142
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.