1+ /**
2+ * @extends {Record<string, any> }
3+ */
14export class Attributes {
25 static $nonscope : boolean ;
36 /**
7+ * Creates an Attributes instance.
8+ *
9+ * There are two construction modes:
10+ *
11+ * 1. **Fresh instance** (no `attributesToCopy`):
12+ * - Used when compiling a DOM element for the first time.
13+ * - Initializes a new `$attr` map to track normalized → DOM attribute names.
14+ *
15+ * 2. **Clone instance** (`attributesToCopy` provided):
16+ * - Used when cloning attributes for directive linking / child scopes.
17+ * - Performs a shallow copy of all properties from the source Attributes object,
18+ * including `$attr`, normalized attribute values, and internal fields
19+ * (e.g. `$$observers`).
20+ * - `$attr` is intentionally **not reinitialized** in this case, because the
21+ * source object already contains the correct normalized → DOM attribute mapping.
22+ *
423 * @param {ng.AnimateService } $animate
524 * @param {ng.ExceptionHandlerService } $exceptionHandler
625 * @param {* } $sce
@@ -17,6 +36,10 @@ export class Attributes {
1736 _$animate : import ( "../../animations/interface.ts" ) . AnimateService ;
1837 _$exceptionHandler : import ( "../../services/exception/interface.ts" ) . ExceptionHandler ;
1938 _$sce : any ;
39+ /**
40+ * A map of DOM element attribute names to the normalized name. This is needed
41+ * to do reverse lookup from normalized name back to actual name.
42+ */
2043 $attr : { } ;
2144 /** @type {import("../../shared/noderef.js").NodeRef } */
2245 $nodeRef : import ( "../../shared/noderef.js" ) . NodeRef ;
@@ -71,20 +94,21 @@ export class Attributes {
7194 attrName ?: string | undefined ,
7295 ) : void ;
7396 /**
97+ * @template T
7498 * Observes an interpolated attribute.
7599 *
76100 * The observer function will be invoked once during the next `$digest` following
77101 * compilation. The observer is then invoked whenever the interpolated value
78102 * changes.
79103 *
80104 * @param {string } key Normalized key. (ie ngAttribute) .
81- * @param {any } fn Function that will be called whenever
105+ * @param {(value?: T) => any } fn Function that will be called whenever
82106 the interpolated value of the attribute changes.
83107 * See the {@link guide/interpolation#how-text-and-attribute-bindings-work Interpolation
84108 * guide} for more info.
85- * @returns {function() } Returns a deregistration function for this observer.
109+ * @returns {Function } Returns a deregistration function for this observer.
86110 */
87- $observe ( key : string , fn : any ) : ( ) => any ;
111+ $observe < T > ( key : string , fn : ( value ?: T ) => any ) : Function ;
88112 $$observers : any ;
89113 setSpecialAttr ( element : any , attrName : any , value : any ) : void ;
90114 /**
0 commit comments