Skip to content

Commit eccaf00

Browse files
committed
use component.name
1 parent 32d8b86 commit eccaf00

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function client_component(source, analysis, options) {
270270
b.id('$$props'),
271271
b.array(bindable),
272272
b.array(exports),
273-
b.id(`${analysis.name}.filename`)
273+
b.id(`${analysis.name}`)
274274
)
275275
)
276276
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ export function loop_guard(timeout) {
8686
* @param {Record<string, any>} $$props
8787
* @param {string[]} bindable
8888
* @param {string[]} exports
89-
* @param {string} filename
89+
* @param {Function & { filename: string }} component
9090
*/
91-
export function validate_prop_bindings($$props, bindable, exports, filename = '') {
91+
export function validate_prop_bindings($$props, bindable, exports, component) {
9292
for (const key in $$props) {
9393
var setter = get_descriptor($$props, key)?.set;
94-
var name = filename.split('/').pop()?.split('.')[0] || 'Component';
94+
var name = component.name;
9595

9696
if (setter) {
9797
if (exports.includes(key)) {
9898
throw new Error(
99-
`Component ${filename} has an export named ${key} that a consumer component is trying to access using bind:${key}, which is disallowed. ` +
99+
`Component ${component.filename} has an export named ${key} that a consumer component is trying to access using bind:${key}, which is disallowed. ` +
100100
`Instead, use bind:this (e.g. <${name} bind:this={component} />) ` +
101101
`and then access the property on the bound component instance (e.g. component.${key}).`
102102
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export default test({
55
dev: true // to ensure we we catch the error
66
},
77
error:
8-
'Component .../samples/export-binding/Counter.svelte has an export named increment that a consumer component is trying to access using bind:increment, which is disallowed. ' +
8+
'Component .../export-binding/counter/index.svelte has an export named increment that a consumer component is trying to access using bind:increment, which is disallowed. ' +
99
'Instead, use bind:this (e.g. <Counter bind:this={component} />) and then access the property on the bound component instance (e.g. component.increment).'
1010
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
2-
import Counter from './Counter.svelte';
2+
import Counter from './counter/index.svelte';
33
let increment;
44
</script>
55

66
<Counter bind:increment={increment} />
7-
<button onclick={increment}>increment</button>
7+
<button onclick={increment}>increment</button>

0 commit comments

Comments
 (0)