fix: ensure onMount correctly fires when new expressions are used (#14049)

* fix: ensure onMount correctly fires when used externally

* fix root context

* fix root context

* revert

* alternative fix
pull/14056/head
Dominic Gannaway 10 months ago committed by GitHub
parent cdec39afac
commit 4a5a0b15d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure onMount correctly fires when new expressions are used

@ -11,5 +11,7 @@ export function NewExpression(node, context) {
w.perf_avoid_inline_class(node);
}
context.state.analysis.needs_context = true;
context.next();
}

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
async test({ assert, logs }) {
assert.deepEqual(logs, ['mounted']);
}
});

@ -0,0 +1,13 @@
<script module>
import { onMount } from 'svelte';
class MyClass {
constructor() {
onMount(() => console.log('mounted'));
}
}
</script>
<script>
new MyClass();
</script>
Loading…
Cancel
Save