Skip to content

Commit

Permalink
extend config
Browse files Browse the repository at this point in the history
  • Loading branch information
ECorreia45 committed Dec 15, 2024
1 parent f3891f6 commit 93fe447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beforesemicolon/web-component",
"version": "1.15.3",
"version": "1.16.0",
"description": "Enhanced Markup with ability to create native Web Components",
"engines": {
"node": ">=18.16.0"
Expand Down
12 changes: 8 additions & 4 deletions src/web-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ const stringToSheet = (css: string) => {

interface WebComponentConfig {
shadow?: boolean
// https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#options
mode?: 'closed' | 'open'
delegatesFocus?: boolean
clonable?: boolean
serializable?: boolean
slotAssignment?: 'named' | 'manual'
}

const defaultConfig: WebComponentConfig = {
shadow: true,
mode: 'open',
delegatesFocus: false,
clonable: false,
serializable: false,
slotAssignment: 'named',
}

const reservedPropNames =
Expand Down Expand Up @@ -269,10 +276,7 @@ export abstract class WebComponent<
this.#renderContent()
} else {
if (config.shadow && !(this.#el instanceof ShadowRoot)) {
this.#el = this.attachShadow({
mode: config.mode ?? 'open',
delegatesFocus: config.delegatesFocus,
})
this.#el = this.attachShadow(config as ShadowRootInit)
}

this.#propNames.forEach((propName) => {
Expand Down

0 comments on commit 93fe447

Please sign in to comment.