-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Description
The generator allows target
to be optional when instantiating a component (cf. https://github.com/sveltejs/svelte/blob/master/src/generate/index.js#L445).
It will always call onrender
though, whether or not the component was mounted or not (cf. https://github.com/sveltejs/svelte/blob/master/src/generate/index.js#L461).
Expected Behavior
- On render is only called when the component is mounted to the DOM for the first time
Example
For a component like this:
FOO
<script>
export default {
onrender() { ... }
}
</script>
the generator will currently create the following code snippet:
function SvelteComponent(options) {
...
if (options.target) this._mount(options.target);
if (options.root) {
options.root.__renderHooks.push({ fn: template.onrender, context: this });
} else {
template.onrender.call(this);
}
....
}
Metadata
Metadata
Assignees
Labels
No labels