Skip to content

Commit

Permalink
feat: do nothing instead of warning when binding a non-existent prop
Browse files Browse the repository at this point in the history
  • Loading branch information
oscard0m committed Oct 20, 2024
1 parent 351b3e7 commit c6dc740
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .changeset/nervous-pans-call.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'svelte': patch
---

fix: warn instead of error when binding a non-existent prop
fix: do not error when binding a non-existent prop
4 changes: 0 additions & 4 deletions packages/svelte/messages/client-warnings/warnings.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## binding_non_existent_prop

> A component is attempting to bind to a non-existent property `%key%` belonging to %component% (i.e. `<%name% bind:%key%={...}>`)
## binding_property_non_reactive

> `%binding%` is binding to a non-reactive property
Expand Down
1 change: 0 additions & 1 deletion packages/svelte/src/internal/client/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export function validate_prop_bindings(
if (has_rest || non_bindable.includes(key)) {
e.bind_not_bindable(key, component[FILENAME], name);
}
w.binding_non_existent_prop(key, component[FILENAME], name);
}
}
}
Expand Down
15 changes: 0 additions & 15 deletions packages/svelte/src/internal/client/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@ import { DEV } from 'esm-env';
var bold = 'font-weight: bold';
var normal = 'font-weight: normal';

/**
* A component is attempting to bind to a non-existent property `%key%` belonging to %component% (i.e. `<%name% bind:%key%={...}>`)
* @param {string} key
* @param {string} component
* @param {string} name
*/
export function binding_non_existent_prop(key, component, name) {
if (DEV) {
console.warn(`%c[svelte] binding_non_existent_prop\n%cA component is attempting to bind to a non-existent property \`${key}\` belonging to ${component} (i.e. \`<${name} bind:${key}={...}>\`)`, bold, normal);
} else {
// TODO print a link to the documentation
console.warn("binding_non_existent_prop");
}
}

/**
* `%binding%` (%location%) is binding to a non-reactive property
* @param {string} binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ import { test } from '../../test';
export default test({
compileOptions: {
dev: true
},

warnings: [
'A component is attempting to bind to a non-existent property `content` belonging to Input.svelte (i.e. `<Input bind:content={...}>`)'
]
}
});

0 comments on commit c6dc740

Please sign in to comment.