Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-otters-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: remove bindable prop validation
Original file line number Diff line number Diff line change
Expand Up @@ -299,28 +299,6 @@ export function client_component(analysis, options) {
(binding.kind === 'prop' || binding.kind === 'bindable_prop') && !name.startsWith('$$')
);

if (dev && analysis.runes) {
const exports = analysis.exports.map(({ name, alias }) => b.literal(alias ?? name));
/** @type {ESTree.Literal[]} */
const bindable = [];
for (const [name, binding] of properties) {
if (binding.kind === 'bindable_prop') {
bindable.push(b.literal(binding.prop_alias ?? name));
}
}
instance.body.unshift(
b.stmt(
b.call(
'$.validate_prop_bindings',
b.id('$$props'),
b.array(bindable),
b.array(exports),
b.id(`${analysis.name}`)
)
)
);
}

if (analysis.accessors) {
for (const [name, binding] of properties) {
const key = binding.prop_alias ?? name;
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export {
setContext,
hasContext
} from './runtime.js';
export { validate_binding, validate_each_keys, validate_prop_bindings } from './validate.js';
export { validate_binding, validate_each_keys } from './validate.js';
export { raf } from './timing.js';
export { proxy } from './proxy.js';
export { create_custom_element } from './dom/elements/custom-element.js';
Expand Down
6 changes: 4 additions & 2 deletions packages/svelte/src/internal/client/reactivity/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,10 @@ export function prop(props, key, flags, fallback) {
var is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;

var setter =
get_descriptor(props, key)?.set ??
(is_entry_props && bindable && key in props ? (v) => (props[key] = v) : undefined);
(bindable &&
(get_descriptor(props, key)?.set ??
(is_entry_props && key in props && ((v) => (props[key] = v))))) ||
undefined;

var fallback_value = /** @type {V} */ (fallback);
var fallback_dirty = true;
Expand Down
25 changes: 1 addition & 24 deletions packages/svelte/src/internal/client/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dev_current_component_function } from './runtime.js';
import { get_descriptor, is_array } from '../shared/utils.js';
import { is_array } from '../shared/utils.js';
import * as e from './errors.js';
import { FILENAME } from '../../constants.js';
import { render_effect } from './reactivity/effects.js';
Expand Down Expand Up @@ -38,29 +38,6 @@ export function validate_each_keys(collection, key_fn) {
});
}

/**
* @param {Record<string, any>} $$props
* @param {string[]} bindable
* @param {string[]} exports
* @param {Function & { [FILENAME]: string }} component
*/
export function validate_prop_bindings($$props, bindable, exports, component) {
for (const key in $$props) {
var setter = get_descriptor($$props, key)?.set;
var name = component.name;

if (setter) {
if (exports.includes(key) && !bindable.includes(key)) {
e.bind_invalid_export(component[FILENAME], key, name);
}

if (!bindable.includes(key)) {
e.bind_not_bindable(key, component[FILENAME], name);
}
}
}
}

/**
* @param {string} binding
* @param {() => Record<string, any>} get_object
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading