@@ -121,13 +121,16 @@ export class FormController {
121121 ] ;
122122
123123 /**
124- * @param {Element } $element
124+ * @param {HTMLFormElement } $element
125125 * @param {ng.Attributes } $attrs
126126 * @param {ng.Scope } $scope
127127 * @param {ng.AnimateService } $animate
128128 * @param {ng.InterpolateService } $interpolate
129129 */
130130 constructor ( $element , $attrs , $scope , $animate , $interpolate ) {
131+ /** @type {boolean } */
132+ this . _isAnimated = hasAnimate ( $element ) ;
133+
131134 this . _controls = [ ] ;
132135
133136 this . $name = $interpolate ( $attrs . name || $attrs . ngForm || "" ) ( $scope ) ;
@@ -491,16 +494,6 @@ export class FormController {
491494 }
492495 }
493496
494- function cachedToggleClass ( ctrl , className , switchValue ) {
495- if ( switchValue && ! ctrl . _classCache [ className ] ) {
496- ctrl . _animate . addClass ( ctrl . _element , className ) ;
497- ctrl . _classCache [ className ] = true ;
498- } else if ( ! switchValue && ctrl . _classCache [ className ] ) {
499- ctrl . _animate . removeClass ( ctrl . _element , className ) ;
500- ctrl . _classCache [ className ] = false ;
501- }
502- }
503-
504497 function toggleValidationCss ( ctrl , validationErrorKeyParam , isValid ) {
505498 validationErrorKeyParam = validationErrorKeyParam
506499 ? `-${ snakeCase ( validationErrorKeyParam , "-" ) } `
@@ -732,3 +725,26 @@ export function setupValidity(instance) {
732725 instance . _classCache [ INVALID_CLASS ] = ! ( instance . _classCache [ VALID_CLASS ] =
733726 instance . _element . classList . contains ( VALID_CLASS ) ) ;
734727}
728+
729+ /**
730+ * @param {FormController|ng.NgModelController } ctrl
731+ * @param {string } className
732+ * @param {boolean } switchValue
733+ */
734+ export function cachedToggleClass ( ctrl , className , switchValue ) {
735+ if ( switchValue && ! ctrl . _classCache [ className ] ) {
736+ if ( ctrl . _isAnimated ) {
737+ ctrl . _animate . addClass ( ctrl . _element , className ) ;
738+ } else {
739+ ctrl . _element . classList . add ( className ) ;
740+ }
741+ ctrl . _classCache [ className ] = true ;
742+ } else if ( ! switchValue && ctrl . _classCache [ className ] ) {
743+ if ( ctrl . _isAnimated ) {
744+ ctrl . _animate . removeClass ( ctrl . _element , className ) ;
745+ } else {
746+ ctrl . _element . classList . remove ( className ) ;
747+ }
748+ ctrl . _classCache [ className ] = false ;
749+ }
750+ }
0 commit comments