@@ -157,10 +157,13 @@ if (typeof HTMLElement === 'function') {
157
157
158
158
constructor (
159
159
private $$componentCtor : ComponentType ,
160
- private $$slots : string [ ]
160
+ private $$slots : string [ ] ,
161
+ use_shadow_dom : boolean
161
162
) {
162
163
super ( ) ;
163
- this . attachShadow ( { mode : 'open' } ) ;
164
+ if ( use_shadow_dom ) {
165
+ this . attachShadow ( { mode : 'open' } ) ;
166
+ }
164
167
}
165
168
166
169
addEventListener ( type : string , listener : any , options ?: any ) : void {
@@ -237,7 +240,7 @@ if (typeof HTMLElement === 'function') {
237
240
}
238
241
239
242
this . $$component = new this . $$componentCtor ( {
240
- target : this . shadowRoot ! ,
243
+ target : this . shadowRoot || this ,
241
244
props : {
242
245
...this . $$data ,
243
246
$$slots,
@@ -330,17 +333,19 @@ interface CustomElementPropDefinition {
330
333
* @param props_definition The props to observe
331
334
* @param slots The slots to create
332
335
* @param accessors Other accessors besides the ones for props the component has
336
+ * @param use_shadow_dom Whether to use shadow DOM
333
337
* @returns A custom element class
334
338
*/
335
339
export function create_custom_element (
336
340
Component : ComponentType ,
337
341
props_definition : Record < string , CustomElementPropDefinition > ,
338
342
slots : string [ ] ,
339
- accessors : string [ ]
343
+ accessors : string [ ] ,
344
+ use_shadow_dom : boolean
340
345
) {
341
346
const Class = class extends SvelteElement {
342
347
constructor ( ) {
343
- super ( Component , slots ) ;
348
+ super ( Component , slots , use_shadow_dom ) ;
344
349
this . $$props_definition = props_definition ;
345
350
}
346
351
0 commit comments