diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 5a2a966d0b..c2615ac85f 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -120,7 +120,7 @@ export function init(component, options, instance, create_fragment, not_equal, p on_disconnect: [], before_update: [], after_update: [], - context: new Map(parent_component ? parent_component.$$.context : []), + context: new Map(parent_component ? parent_component.$$.context : options.context ? Object.entries(options.context) : []), // everything else callbacks: blank_object(), diff --git a/src/runtime/tsconfig.json b/src/runtime/tsconfig.json index f3b4691b41..34f48ccfaf 100644 --- a/src/runtime/tsconfig.json +++ b/src/runtime/tsconfig.json @@ -3,7 +3,7 @@ "include": ["."], "compilerOptions": { - "lib": ["es2015", "dom", "dom.iterable"], + "lib": ["es2017", "dom", "dom.iterable"], "target": "es2015", "types": [], diff --git a/test/runtime/samples/constructor-pass-context/Component.svelte b/test/runtime/samples/constructor-pass-context/Component.svelte new file mode 100644 index 0000000000..ae27a0d57a --- /dev/null +++ b/test/runtime/samples/constructor-pass-context/Component.svelte @@ -0,0 +1,9 @@ + + +
{value}
+'); + + const button = target.querySelector('button'); + await button.dispatchEvent(new window.MouseEvent('click')); + + assert.deepEqual(called, ['hello world']); + + component.$destroy(); + } +}; diff --git a/test/runtime/samples/constructor-pass-context/main.svelte b/test/runtime/samples/constructor-pass-context/main.svelte new file mode 100644 index 0000000000..e69de29bb2