|
1 | 1 | import { createClassComponent } from '../../../../legacy/legacy-client.js';
|
2 |
| -import { destroy_effect, render_effect } from '../../reactivity/effects.js'; |
| 2 | +import { destroy_effect, effect_root, render_effect } from '../../reactivity/effects.js'; |
3 | 3 | import { append } from '../template.js';
|
4 | 4 | import { define_property, get_descriptor, object_keys } from '../../../shared/utils.js';
|
5 | 5 |
|
@@ -145,24 +145,26 @@ if (typeof HTMLElement === 'function') {
|
145 | 145 | });
|
146 | 146 |
|
147 | 147 | // Reflect component props as attributes
|
148 |
| - this.$$me = render_effect(() => { |
149 |
| - this.$$r = true; |
150 |
| - for (const key of object_keys(this.$$c)) { |
151 |
| - if (!this.$$p_d[key]?.reflect) continue; |
152 |
| - this.$$d[key] = this.$$c[key]; |
153 |
| - const attribute_value = get_custom_element_value( |
154 |
| - key, |
155 |
| - this.$$d[key], |
156 |
| - this.$$p_d, |
157 |
| - 'toAttribute' |
158 |
| - ); |
159 |
| - if (attribute_value == null) { |
160 |
| - this.removeAttribute(this.$$p_d[key].attribute || key); |
161 |
| - } else { |
162 |
| - this.setAttribute(this.$$p_d[key].attribute || key, attribute_value); |
| 148 | + this.$$me = effect_root(() => { |
| 149 | + render_effect(() => { |
| 150 | + this.$$r = true; |
| 151 | + for (const key of object_keys(this.$$c)) { |
| 152 | + if (!this.$$p_d[key]?.reflect) continue; |
| 153 | + this.$$d[key] = this.$$c[key]; |
| 154 | + const attribute_value = get_custom_element_value( |
| 155 | + key, |
| 156 | + this.$$d[key], |
| 157 | + this.$$p_d, |
| 158 | + 'toAttribute' |
| 159 | + ); |
| 160 | + if (attribute_value == null) { |
| 161 | + this.removeAttribute(this.$$p_d[key].attribute || key); |
| 162 | + } else { |
| 163 | + this.setAttribute(this.$$p_d[key].attribute || key, attribute_value); |
| 164 | + } |
163 | 165 | }
|
164 |
| - } |
165 |
| - this.$$r = false; |
| 166 | + this.$$r = false; |
| 167 | + }); |
166 | 168 | });
|
167 | 169 |
|
168 | 170 | for (const type in this.$$l) {
|
@@ -196,7 +198,7 @@ if (typeof HTMLElement === 'function') {
|
196 | 198 | Promise.resolve().then(() => {
|
197 | 199 | if (!this.$$cn && this.$$c) {
|
198 | 200 | this.$$c.$destroy();
|
199 |
| - destroy_effect(this.$$me); |
| 201 | + this.$$me(); |
200 | 202 | this.$$c = undefined;
|
201 | 203 | }
|
202 | 204 | });
|
|
0 commit comments