@@ -4,7 +4,13 @@ import { tick } from 'svelte'
4
4
const containerCache = new Map ( )
5
5
const componentCache = new Set ( )
6
6
7
- const svleteComponentOptions = [ 'anchor' , 'props' , 'hydrate' , 'intro' ]
7
+ const svelteComponentOptions = [
8
+ 'anchor' ,
9
+ 'props' ,
10
+ 'hydrate' ,
11
+ 'intro' ,
12
+ 'context'
13
+ ]
8
14
9
15
const render = (
10
16
Component ,
@@ -17,19 +23,21 @@ const render = (
17
23
const ComponentConstructor = Component . default || Component
18
24
19
25
const checkProps = ( options ) => {
20
- const isProps = ! Object . keys ( options ) . some ( option => svleteComponentOptions . includes ( option ) )
26
+ const isProps = ! Object . keys ( options ) . some ( ( option ) =>
27
+ svelteComponentOptions . includes ( option )
28
+ )
21
29
22
30
// Check if any props and Svelte options were accidentally mixed.
23
31
if ( ! isProps ) {
24
- const unrecognizedOptions = Object
25
- . keys ( options )
26
- . filter ( option => ! svleteComponentOptions . includes ( option ) )
32
+ const unrecognizedOptions = Object . keys ( options ) . filter (
33
+ ( option ) => ! svelteComponentOptions . includes ( option )
34
+ )
27
35
28
36
if ( unrecognizedOptions . length > 0 ) {
29
37
throw Error ( `
30
- Unknown options were found [${ unrecognizedOptions } ]. This might happen if you've mixed
31
- passing in props with Svelte options into the render function. Valid Svelte options
32
- are [${ svleteComponentOptions } ]. You can either change the prop names, or pass in your
38
+ Unknown options were found [${ unrecognizedOptions } ]. This might happen if you've mixed
39
+ passing in props with Svelte options into the render function. Valid Svelte options
40
+ are [${ svelteComponentOptions } ]. You can either change the prop names, or pass in your
33
41
props for that component via the \`props\` option.\n\n
34
42
Eg: const { /** Results **/ } = render(MyComponent, { props: { /** props here **/ } })\n\n
35
43
` )
@@ -76,7 +84,7 @@ const render = (
76
84
}
77
85
}
78
86
79
- const cleanupAtContainer = container => {
87
+ const cleanupAtContainer = ( container ) => {
80
88
const { target, component } = containerCache . get ( container )
81
89
82
90
if ( componentCache . has ( component ) ) component . $destroy ( )
0 commit comments