https://github.com/angular/angular
Revision 899218de1f4b373cba076299ea65ff5e2a6a1912 authored by Andrew Kushnir on 28 July 2020, 02:31:40 UTC, committed by Alex Rickabaugh on 28 October 2020, 16:48:21 UTC
This commit refactors validators-related logic that is common across most of the directives.

A couple notes on this refactoring:
* common logic was moved to the `AbstractControlDirective` class (including `validator` and
`asyncValidator` getters)
* sync/async validators are now composed in `AbstractControlDirective` class eagerly when validators
are set with `_setValidators` and `_setAsyncValidators` calls and the result is stored in directive
instance (thus getters return cached versions of validator fn). This is needed to make sure composed
validator function remains the same (retains its identity) for a given directive instance, so that
this function can be added and later removed from an instance of an AbstractControl-based class
(like `FormControl`). Preserving validator function is required to perform proper cleanup (in followup
PRs) of the AbstractControl-based classes when a directive is destroyed.

PR Close #38280
1 parent 399f491
History
Tip revision: 899218de1f4b373cba076299ea65ff5e2a6a1912 authored by Andrew Kushnir on 28 July 2020, 02:31:40 UTC
refactor(forms): move common validators-related logic to the `AbstractControlDirective` class (#38280)
Tip revision: 899218d
File Mode Size
.circleci
.devcontainer
.github
.ng-dev
.vscode
.yarn
aio
dev-infra
docs
goldens
integration
modules
packages
scripts
third_party
tools
.bazelignore -rw-r--r-- 4.3 KB
.bazelrc -rw-r--r-- 6.2 KB
.bazelversion -rw-r--r-- 213 bytes
.clang-format -rw-r--r-- 73 bytes
.editorconfig -rw-r--r-- 245 bytes
.gitattributes -rw-r--r-- 314 bytes
.gitignore -rw-r--r-- 837 bytes
.gitmessage -rw-r--r-- 7.2 KB
.mailmap -rw-r--r-- 51 bytes
.nvmrc -rw-r--r-- 8 bytes
.pullapprove.yml -rw-r--r-- 45.3 KB
.yarnrc -rw-r--r-- 128 bytes
BUILD.bazel -rw-r--r-- 1.8 KB
CHANGELOG.md -rw-r--r-- 754.5 KB
CODE_OF_CONDUCT.md -rw-r--r-- 1.1 KB
CONTRIBUTING.md -rw-r--r-- 14.9 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 4.3 KB
WORKSPACE -rw-r--r-- 4.0 KB
browser-providers.conf.js -rw-r--r-- 8.4 KB
gulpfile.js -rw-r--r-- 1.3 KB
karma-js.conf.js -rw-r--r-- 7.8 KB
package.json -rw-r--r-- 8.3 KB
test-events.js -rw-r--r-- 259 bytes
test-main.js -rw-r--r-- 11.3 KB
tslint.json -rw-r--r-- 2.3 KB
yarn.lock -rw-r--r-- 679.5 KB
yarn.lock.readme.md -rw-r--r-- 1.3 KB

README.md

back to top