Skip to content

Commit

Permalink
Merge pull request #72 from github/use-shadow-dom-for-css
Browse files Browse the repository at this point in the history
Set host element to a block its Shadow DOM
  • Loading branch information
koddsson authored Feb 16, 2022
2 parents aaac785 + 4e090eb commit 324d9b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clean": "rm -rf dist",
"lint": "eslint . --ext .js,.ts && tsc --noEmit",
"prebuild": "npm run clean && npm run lint && mkdir dist",
"build": "tsc && cp src/index.css dist/index.css",
"build": "tsc",
"pretest": "npm run build",
"test": "karma start ./test/karma.config.cjs",
"prepublishOnly": "npm run build",
Expand Down
4 changes: 0 additions & 4 deletions src/index.css

This file was deleted.

11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ export default class IncludeFragmentElement extends HTMLElement {
}
}

constructor() {
super()
this.attachShadow({mode: 'open'}).innerHTML = `
<style>
:host {
display: block;
}
</style>
<slot></slot>`
}

connectedCallback(): void {
if (this.src && this.loading === 'eager') {
handleData(this)
Expand Down

0 comments on commit 324d9b5

Please sign in to comment.