diff --git a/site/content/docs/03-run-time.md b/site/content/docs/03-run-time.md index 4f32ea682b..af15c950cd 100644 --- a/site/content/docs/03-run-time.md +++ b/site/content/docs/03-run-time.md @@ -1088,16 +1088,22 @@ You can call the `.render()` with the following parameters: | option | default | description | | --- | --- | --- | | `props` | `{}` | An object of properties to supply to the component -| `slots` | `{}` | A object of slots to supply to the component +| `options` | `{}` | An object of options + +The `options` object takes in the following properties: +| key | default | description | +| --- | --- | --- | +| `slots` | `{}` | slots to supply to the component | `context` | `new Map()` | A `Map` of context key-value pairs to supply to the component ```js const { head, html, css } = App.render( // props { answer: 42 }, - // slots - { 'slot-a': (lets) => 'hello world' }, - // contexts - new Map([['context-key', 'context-value']]), + // options + { + slots: { 'slot-a': (lets) => 'hello world' }, + context: new Map([['context-key', 'context-value']]), + } ); ``` \ No newline at end of file diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 9ae49fc717..8257734ef8 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -97,7 +97,7 @@ export function create_ssr_component(fn) { } return { - render: (props = {}, slots = {}, context = new Map()) => { + render: (props = {}, { slots = {}, context = new Map() } = {}) => { on_destroy = []; const result: { diff --git a/src/runtime/tsconfig.json b/src/runtime/tsconfig.json index 34f48ccfaf..f3b4691b41 100644 --- a/src/runtime/tsconfig.json +++ b/src/runtime/tsconfig.json @@ -3,7 +3,7 @@ "include": ["."], "compilerOptions": { - "lib": ["es2017", "dom", "dom.iterable"], + "lib": ["es2015", "dom", "dom.iterable"], "target": "es2015", "types": [], diff --git a/test/runtime/samples/constructor-pass-context/_config.js b/test/runtime/samples/constructor-pass-context/_config.js index 2e45032b1e..02b58f5451 100644 --- a/test/runtime/samples/constructor-pass-context/_config.js +++ b/test/runtime/samples/constructor-pass-context/_config.js @@ -23,10 +23,10 @@ export default { const Component = require('./Component.svelte').default; const called = []; - const { html } = Component.render(undefined, undefined, new Map([ + const { html } = Component.render(undefined, { context: new Map([ ['key', 'svelte'], ['fn', (value) => called.push(value)] - ])); + ]) }); assert.htmlEqual(html, '
svelte
'); } }; diff --git a/test/server-side-rendering/index.ts b/test/server-side-rendering/index.ts index f44bf17ab9..e81058181d 100644 --- a/test/server-side-rendering/index.ts +++ b/test/server-side-rendering/index.ts @@ -13,6 +13,7 @@ import { shouldUpdateExpected, mkdirp } from '../helpers'; +import { set_current_component } from '../../internal'; function tryToReadFile(file) { try { @@ -127,6 +128,8 @@ describe('ssr', () => { showOutput(dir, { generate: 'ssr', format: 'cjs' }); err.stack += `\n\ncmd-click: ${path.relative(process.cwd(), dir)}/main.svelte`; throw err; + } finally { + set_current_component(null); } }); }); @@ -223,6 +226,8 @@ describe('ssr', () => { showOutput(cwd, compileOptions); throw err; } + } finally { + set_current_component(null); } }); });