Skip to content

Commit ce4f972

Browse files
authored
fix: remove bindable prop validation (#14946)
1 parent 9b71eea commit ce4f972

File tree

14 files changed

+11
-124
lines changed

14 files changed

+11
-124
lines changed

.changeset/flat-otters-cheer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: remove bindable prop validation

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -299,28 +299,6 @@ export function client_component(analysis, options) {
299299
(binding.kind === 'prop' || binding.kind === 'bindable_prop') && !name.startsWith('$$')
300300
);
301301

302-
if (dev && analysis.runes) {
303-
const exports = analysis.exports.map(({ name, alias }) => b.literal(alias ?? name));
304-
/** @type {ESTree.Literal[]} */
305-
const bindable = [];
306-
for (const [name, binding] of properties) {
307-
if (binding.kind === 'bindable_prop') {
308-
bindable.push(b.literal(binding.prop_alias ?? name));
309-
}
310-
}
311-
instance.body.unshift(
312-
b.stmt(
313-
b.call(
314-
'$.validate_prop_bindings',
315-
b.id('$$props'),
316-
b.array(bindable),
317-
b.array(exports),
318-
b.id(`${analysis.name}`)
319-
)
320-
)
321-
);
322-
}
323-
324302
if (analysis.accessors) {
325303
for (const [name, binding] of properties) {
326304
const key = binding.prop_alias ?? name;

packages/svelte/src/internal/client/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export {
150150
setContext,
151151
hasContext
152152
} from './runtime.js';
153-
export { validate_binding, validate_each_keys, validate_prop_bindings } from './validate.js';
153+
export { validate_binding, validate_each_keys } from './validate.js';
154154
export { raf } from './timing.js';
155155
export { proxy } from './proxy.js';
156156
export { create_custom_element } from './dom/elements/custom-element.js';

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,10 @@ export function prop(props, key, flags, fallback) {
297297
var is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;
298298

299299
var setter =
300-
get_descriptor(props, key)?.set ??
301-
(is_entry_props && bindable && key in props ? (v) => (props[key] = v) : undefined);
300+
(bindable &&
301+
(get_descriptor(props, key)?.set ??
302+
(is_entry_props && key in props && ((v) => (props[key] = v))))) ||
303+
undefined;
302304

303305
var fallback_value = /** @type {V} */ (fallback);
304306
var fallback_dirty = true;

packages/svelte/src/internal/client/validate.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { dev_current_component_function } from './runtime.js';
2-
import { get_descriptor, is_array } from '../shared/utils.js';
2+
import { is_array } from '../shared/utils.js';
33
import * as e from './errors.js';
44
import { FILENAME } from '../../constants.js';
55
import { render_effect } from './reactivity/effects.js';
@@ -38,29 +38,6 @@ export function validate_each_keys(collection, key_fn) {
3838
});
3939
}
4040

41-
/**
42-
* @param {Record<string, any>} $$props
43-
* @param {string[]} bindable
44-
* @param {string[]} exports
45-
* @param {Function & { [FILENAME]: string }} component
46-
*/
47-
export function validate_prop_bindings($$props, bindable, exports, component) {
48-
for (const key in $$props) {
49-
var setter = get_descriptor($$props, key)?.set;
50-
var name = component.name;
51-
52-
if (setter) {
53-
if (exports.includes(key) && !bindable.includes(key)) {
54-
e.bind_invalid_export(component[FILENAME], key, name);
55-
}
56-
57-
if (!bindable.includes(key)) {
58-
e.bind_not_bindable(key, component[FILENAME], name);
59-
}
60-
}
61-
}
62-
}
63-
6441
/**
6542
* @param {string} binding
6643
* @param {() => Record<string, any>} get_object

packages/svelte/tests/runtime-runes/samples/export-binding/_config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/svelte/tests/runtime-runes/samples/export-binding/counter/index.svelte

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/svelte/tests/runtime-runes/samples/export-binding/main.svelte

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/svelte/tests/runtime-runes/samples/props-not-bindable-spread/Counter.svelte

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/svelte/tests/runtime-runes/samples/props-not-bindable-spread/_config.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)