Skip to content

Commit be309d5

Browse files
Flarettemattrbeck
authored andcommitted
refactor(forms): correct the InputValidityMonitor doc comment
The comment said the service installs a CSS transition and listens for `transitionstart`. Since it was introduced, the service has installed `@keyframes` animations and listened for `animationstart`. Describe what the code does, and rename the private `createTransitionStyle()` to `createAnimationStyle()` to match. (cherry picked from commit 4570715)
1 parent 39294fb commit be309d5

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎packages/forms/signals/src/directive/input_validity_monitor.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import {
1919
/**
2020
* Service that monitors validity state changes on native form elements.
2121
*
22-
* It works by dynamically installing a CSS transition on `input, textarea` `:valid`
23-
* and `:invalid` states, which allows us to intercept a `transitionstart` event
24-
* whenever the native validity state changes without an `input` event (e.g. clearing a date input).
22+
* It works by dynamically installing a CSS animation on the `:valid` and `:invalid` states of
23+
* `input` and `textarea` elements. Each state uses a differently named animation, so a validity
24+
* change restarts the animation and fires an `animationstart` event, even when no `input` event
25+
* fires (e.g. clearing a date input).
2526
*/
2627
@Injectable({providedIn: 'root', useClass: forwardRef(() => AnimationInputValidityMonitor)})
2728
export abstract class InputValidityMonitor {
@@ -51,7 +52,7 @@ export class AnimationInputValidityMonitor extends InputValidityMonitor implemen
5152

5253
const rootNode = element.getRootNode() as Document | ShadowRoot;
5354
if (!this.injectedStyles.has(rootNode)) {
54-
this.injectedStyles.set(rootNode, this.createTransitionStyle(rootNode));
55+
this.injectedStyles.set(rootNode, this.createAnimationStyle(rootNode));
5556
}
5657

5758
const onAnimationStart = (event: Event) => {
@@ -73,7 +74,7 @@ export class AnimationInputValidityMonitor extends InputValidityMonitor implemen
7374
return element.validity?.badInput ?? false;
7475
}
7576

76-
private createTransitionStyle(rootNode: Document | ShadowRoot): HTMLStyleElement {
77+
private createAnimationStyle(rootNode: Document | ShadowRoot): HTMLStyleElement {
7778
const element = this.document.createElement('style');
7879
if (this.cspNonce) {
7980
element.nonce = this.cspNonce;

0 commit comments

Comments
 (0)