pull/15400/head
Dominic Gannaway 1 year ago
parent 157472ff16
commit 5636ee8314

@ -27,5 +27,4 @@ export const LEGACY_PROPS = Symbol('legacy props');
export const TEARDOWN_PROPS = Symbol('teardown props');
export const LOADING_ATTR_SYMBOL = Symbol('');
export const CTX_CONTAINS_TEARDOWN = 1 << 1;
export const CTX_DESTROYED = 1 << 2;
export const CTX_DESTROYED = 1 << 1;

@ -5,7 +5,8 @@ import {
PROPS_IS_IMMUTABLE,
PROPS_IS_LAZY_INITIAL,
PROPS_IS_RUNES,
PROPS_IS_UPDATED
PROPS_IS_UPDATED,
UNINITIALIZED
} from '../../../constants.js';
import { get_descriptor, is_function } from '../../shared/utils.js';
import { mutable_source, set, source, update } from './sources.js';
@ -23,6 +24,7 @@ import {
import { proxy } from '../proxy.js';
import { capture_store_binding } from './store.js';
import { legacy_mode_flag } from '../../flags/index.js';
import { is_runes } from '../context.js';
/**
* @param {((value?: number) => number)} fn
@ -391,6 +393,11 @@ export function prop(props, key, flags, fallback) {
return (inner_current_value.v = parent_value);
});
// Read the prop eagerly to ensure it has a value
if (!is_runes()) {
get(current_value);
}
if (!immutable) current_value.equals = safe_equals;
return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {

@ -22,8 +22,7 @@ import {
ROOT_EFFECT,
LEGACY_DERIVED_PROP,
DISCONNECTED,
BOUNDARY_EFFECT,
CTX_CONTAINS_TEARDOWN
BOUNDARY_EFFECT
} from './constants.js';
import { flush_tasks } from './dom/task.js';
import { internal_set } from './reactivity/sources.js';
@ -567,17 +566,7 @@ export function update_effect(effect) {
execute_effect_teardown(effect);
var teardown = update_reaction(effect);
if (typeof teardown === 'function') {
var ctx = effect.ctx;
if (ctx !== null && (ctx.f & CTX_CONTAINS_TEARDOWN) === 0) {
ctx.f ^= CTX_CONTAINS_TEARDOWN;
}
effect.teardown = teardown;
} else {
effect.teardown = null;
}
effect.teardown = typeof teardown === 'function' ? teardown : null;
effect.wv = write_version;
var deps = effect.deps;

@ -1,11 +1,14 @@
<script>
import { onDestroy } from 'svelte';
import { onDestroy } from "svelte";
export let my_prop;
export let checked;
export let count;
onDestroy(() => {
console.log(my_prop.foo);
console.log(count, checked);
});
</script>
{my_prop.foo}
<p>{count}</p>
<button onclick={()=> count-- }></button>

Loading…
Cancel
Save