@@ -7,13 +7,18 @@ import {
7
7
PROPS_IS_RUNES ,
8
8
PROPS_IS_UPDATED
9
9
} from '../../../constants.js' ;
10
- import { get_descriptor , is_function } from '../../shared/utils.js' ;
10
+ import { define_property , get_descriptor , is_function } from '../../shared/utils.js' ;
11
11
import { mutable_source , set , source , update } from './sources.js' ;
12
12
import { derived , derived_safe_equal } from './deriveds.js' ;
13
13
import { get , captured_signals , untrack } from '../runtime.js' ;
14
14
import { safe_equals } from './equality.js' ;
15
15
import * as e from '../errors.js' ;
16
- import { LEGACY_DERIVED_PROP , LEGACY_PROPS , STATE_SYMBOL } from '../constants.js' ;
16
+ import {
17
+ BINDABLE_FALLBACK_SYMBOL ,
18
+ LEGACY_DERIVED_PROP ,
19
+ LEGACY_PROPS ,
20
+ STATE_SYMBOL
21
+ } from '../constants.js' ;
17
22
import { proxy } from '../proxy.js' ;
18
23
import { capture_store_binding } from './store.js' ;
19
24
import { legacy_mode_flag } from '../../flags/index.js' ;
@@ -304,6 +309,29 @@ export function prop(props, key, flags, fallback) {
304
309
if ( setter ) setter ( prop_value ) ;
305
310
}
306
311
312
+ /**
313
+ * @param {any } value
314
+ */
315
+ function set_bindable_fallback ( value ) {
316
+ if ( DEV && ! setter && fallback_used && value != null && typeof value === 'object' ) {
317
+ // in dev we issue a warning if a bindable prop is passed with bindable
318
+ // to a child if the prop doesn't have a setter but if it's a fallback
319
+ // it's a false positive since the state it's actually created in this
320
+ // component so we store the fact that this is a bindable fallback with
321
+ // a symbol
322
+ define_property ( value , BINDABLE_FALLBACK_SYMBOL , {
323
+ enumerable : false ,
324
+ // it needs to be configurable or the proxy will complain when we return true
325
+ // for a non configurable property
326
+ configurable : true ,
327
+ writable : false ,
328
+ value : true
329
+ } ) ;
330
+ }
331
+ }
332
+
333
+ set_bindable_fallback ( prop_value ) ;
334
+
307
335
/** @type {() => V } */
308
336
var getter ;
309
337
if ( runes ) {
@@ -399,6 +427,11 @@ export function prop(props, key, flags, fallback) {
399
427
if ( arguments . length > 0 ) {
400
428
const new_value = mutation ? get ( current_value ) : runes && bindable ? proxy ( value ) : value ;
401
429
430
+ // we only care to add the symbol if the original prop is reassigned
431
+ if ( runes && bindable && ! mutation ) {
432
+ set_bindable_fallback ( new_value ) ;
433
+ }
434
+
402
435
if ( ! current_value . equals ( new_value ) ) {
403
436
from_child = true ;
404
437
set ( inner_current_value , new_value ) ;
0 commit comments