@@ -7,6 +7,12 @@ import * as w from '../../warnings.js';
77import { LOADING_ATTR_SYMBOL } from '../../constants.js' ;
88import { queue_idle_task , queue_micro_task } from '../task.js' ;
99import { 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' ;
1016
1117/**
1218 * 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) {
145151 * @param {any } value
146152 */
147153export 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 ) ;
152172 }
153173}
154174
0 commit comments