Skip to content

Commit

Permalink
feat(cdk): add @ng-web-apis/mutation-observer (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored Oct 26, 2020
1 parent a52e9ac commit 7459c70
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@nguniversal/module-map-ngfactory-loader": "^7.1.1",
"@ng-web-apis/common": "1.7.0",
"@ng-web-apis/intersection-observer": "2.0.1",
"@ng-web-apis/mutation-observer": "1.1.0",
"@ng-web-apis/resize-observer": "1.0.3",
"@ng-web-apis/universal": "^1.6.0",
"@tinkoff/angular-contenteditable-accessor": "1.1.0",
Expand Down
13 changes: 7 additions & 6 deletions projects/cdk/abstract/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export abstract class AbstractTuiControl<T>
) {
super();

if (ngControl === null) {
if (this.ngControl === null) {
tuiAssert.assert(
false,
`NgControl not injected in ${this.constructor.name}!\n`,
'Use [(ngModel)] or [formControl] or formControlName for correct work.',
);
} else {
ngControl.valueAccessor = this;
this.ngControl.valueAccessor = this;
}
}

Expand Down Expand Up @@ -108,7 +108,7 @@ export abstract class AbstractTuiControl<T>
}

protected get controlName(): string | null {
return this.ngControl === null ? null : this.ngControl.name;
return this.ngControl && this.ngControl.name;
}

private get rawValue(): T | undefined {
Expand Down Expand Up @@ -195,9 +195,10 @@ export abstract class AbstractTuiControl<T>
extractor: (ngControl: NgControl) => T | null | undefined,
defaultFieldValue: T,
): T {
return this.ngControl === null
? defaultFieldValue
: fallbackValue<T>(extractor(this.ngControl), defaultFieldValue);
return fallbackValue<T>(
this.ngControl && extractor(this.ngControl),
defaultFieldValue,
);
}

private controlMarkAsTouched() {
Expand Down
1 change: 1 addition & 0 deletions projects/cdk/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@tinkoff/ng-polymorpheus",
"@tinkoff/ng-event-plugins",
"@ng-web-apis/common",
"@ng-web-apis/mutation-observer",
"@ng-web-apis/resize-observer",
"@types/resize-observer-browser"
],
Expand Down
1 change: 1 addition & 0 deletions projects/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"homepage": "https://github.com/TinkoffCreditSystems/taiga-ui",
"dependencies": {
"@ng-web-apis/common": "1.7.0",
"@ng-web-apis/mutation-observer": "1.1.0",
"@ng-web-apis/resize-observer": "1.0.3",
"@tinkoff/ng-event-plugins": "1.0.1",
"@tinkoff/ng-polymorpheus": "2.1.0",
Expand Down

0 comments on commit 7459c70

Please sign in to comment.