Description
Quick search through issues haven't results, so I will create this.
Is it technically possible to split native attributes and properties into $$attrs and $$props for cases where we need to bind only native attributes to some element?
Something like in Vue realization:
<template>
<label>
{{ label }}
<input
v-bind="$attrs"
>
</label>
</template>
<script>
export default {
inheritAttrs: false,
}
</script>
In Vue it's much cleaner, because component have only one root element. So it's logical to bind attributes to first element. On the other hand, in Svelte it's possible to have several root elements and this is great ability, but may be it's a good idea to allow developers manually control native attributes bindings?
Some stupid example:
// Action.svelte
<button {...$$attrs}>Trigger</button>
<script>
export let endpoint, method;
</script>
// App.svelte
<Action id="some_id" endpoint="http://api.site.com/posts/1/" method="delete"></Action>
<script>
import Action from './Action.svelte';
</script>
// Output
<button id="some_id">Trigger</button>
I think this may be useful in cases when we have many properties and don't want to see all properties zoo in markup. Or it may contain something like unregistered properties, which will exclude all explicitly exported props.
However, if we back to the tutorial. It can be bad idea, because of:
Conversely, if you need to reference all the props that were passed into a component, including ones that weren't declared with export, you can do so by accessing $$props directly. It's not generally recommended, as it's difficult for Svelte to optimise, but it's useful in rare cases.
What do you think?