@@ -35,8 +35,6 @@ export class ParseProvider {
3535 const parser = new Parser ( lexer , $filter ) ;
3636
3737 parsedExpression = parser . _parse ( exp ) ;
38-
39- cache [ cacheKey ] = addWatchDelegate ( parsedExpression ) ;
4038 }
4139
4240 return addInterceptor ( parsedExpression , interceptorFn ) ;
@@ -52,111 +50,36 @@ export class ParseProvider {
5250 return parsedExpression ;
5351 }
5452
55- // Extract any existing interceptors out of the parsedExpression
56- // to ensure the original parsedExpression is always the $$intercepted
57- // @ts -ignore
58- if ( parsedExpression . _interceptor ) {
59- interceptorFn = chainInterceptors (
60- // @ts -ignore
61- parsedExpression . _interceptor ,
62- interceptorFn ,
63- ) ;
64- // @ts -ignore
65- parsedExpression = parsedExpression . $$intercepted ;
66- }
67-
68- const useInputs = false ;
69-
70- const fn = function interceptedExpression (
71- scope ,
72- locals ,
73- assign ,
74- inputs ,
75- ) {
76- const value =
77- useInputs && inputs
78- ? inputs [ 0 ]
79- : parsedExpression ( scope , locals , assign ) ;
80-
53+ /**
54+ *
55+ * @param {ng.Scope } scope
56+ * @param {Object } [locals]
57+ * @param {* } [assign]
58+ * @returns
59+ */
60+ const fn = function interceptedExpression ( scope , locals , assign ) {
8161 // Do not invoke for getters
8262 if ( scope ?. getter ) {
8363 return undefined ;
8464 }
65+ const value = parsedExpression ( scope , locals , assign ) ;
66+
8567 const res = isFunction ( value ) ? value ( ) : value ;
8668
8769 return interceptorFn ( deProxy ( res ) ) ;
8870 } ;
8971
9072 fn . _interceptor = interceptorFn ;
9173
92- // @ts -ignore
9374 fn . _literal = parsedExpression . _literal ;
94- // @ts -ignore
75+
9576 fn . constant = parsedExpression . constant ;
96- // @ts -ignore
77+
9778 fn . _decoratedNode = parsedExpression . _decoratedNode ;
9879
99- return addWatchDelegate ( fn ) ;
80+ return fn ;
10081 }
10182 } ,
10283 ] ;
10384 }
10485}
105-
106- export function constantWatchDelegate ( scope , listener , parsedExpression ) {
107- const unwatch = scope . $watch ( ( ) => {
108- unwatch ( ) ;
109-
110- return parsedExpression ( scope ) ;
111- } , listener ) ;
112-
113- return unwatch ;
114- }
115-
116- /**
117- *
118- * @param {import('./interface.ts').CompiledExpression } parsedExpression
119- * @returns {import('./interface.ts').CompiledExpression }
120- */
121- function addWatchDelegate ( parsedExpression ) {
122- if ( parsedExpression . constant ) {
123- parsedExpression . _watchDelegate = constantWatchDelegate ;
124- } else if ( parsedExpression . _inputs ) {
125- parsedExpression . _watchDelegate = inputsWatchDelegate ;
126- }
127-
128- return parsedExpression ;
129- }
130-
131- /**
132- * Watches input expressions and calls the parsedExpression with their current values.
133- *
134- * @param {ng.Scope } scope
135- * @param {Function } listener - Callback when the expression result changes
136- * @param {import('./interface.ts').CompiledExpression } parsedExpression
137- * @returns {Function } Unwatch function
138- */
139- function inputsWatchDelegate ( scope , listener , parsedExpression ) {
140- const { _inputs : inputs } = parsedExpression ;
141-
142- const getValues = isFunction ( inputs )
143- ? ( ) => inputs ( scope )
144- : ( ) => inputs . map ( ( fn ) => fn ( scope ) ) ;
145-
146- const evaluate = ( ) => parsedExpression ( scope , undefined , getValues ( ) ) ;
147-
148- // Immediately call the listener with the initial value
149- listener ( evaluate ( ) ) ;
150-
151- // Return a reactive/unwatch function
152- return ( ) => {
153- // In AngularTS, reactive triggers would handle updates,
154- // so this is just a placeholder for unwatch cleanup, without any cleanup
155- } ;
156- }
157-
158- function chainInterceptors ( first , second ) {
159- return function chainedInterceptor ( value ) {
160- return second ( first ( value ) ) ;
161- } ;
162- }
0 commit comments