@@ -7,6 +7,12 @@ import * as w from '../../warnings.js';
7
7
import { LOADING_ATTR_SYMBOL } from '../../constants.js' ;
8
8
import { queue_idle_task , queue_micro_task } from '../task.js' ;
9
9
import { is_capture_event , is_delegated , normalize_attribute } from '../../../../utils.js' ;
10
+ import {
11
+ active_effect ,
12
+ active_reaction ,
13
+ set_active_effect ,
14
+ set_active_reaction
15
+ } from '../../runtime.js' ;
10
16
11
17
/**
12
18
* The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
@@ -145,10 +151,24 @@ export function set_xlink_attribute(dom, attribute, value) {
145
151
* @param {any } value
146
152
*/
147
153
export function set_custom_element_data ( node , prop , value ) {
148
- if ( get_setters ( node ) . includes ( prop ) ) {
149
- node [ prop ] = value ;
150
- } else {
151
- set_attribute ( node , prop , value ) ;
154
+ // We need to ensure that setting custom element props, which can
155
+ // invoke lifecycle methods on other custom elements, does not also
156
+ // associate those lifecycle methods with the current active reaction
157
+ // or effect
158
+ var previous_reaction = active_reaction ;
159
+ var previous_effect = active_effect ;
160
+
161
+ set_active_reaction ( null ) ;
162
+ set_active_effect ( null ) ;
163
+ try {
164
+ if ( get_setters ( node ) . includes ( prop ) ) {
165
+ node [ prop ] = value ;
166
+ } else {
167
+ set_attribute ( node , prop , value ) ;
168
+ }
169
+ } finally {
170
+ set_active_reaction ( previous_reaction ) ;
171
+ set_active_effect ( previous_effect ) ;
152
172
}
153
173
}
154
174
0 commit comments