Skip to content

Commit 324d9b5

Browse files
authored
Merge pull request #72 from github/use-shadow-dom-for-css
Set host element to a block its Shadow DOM
2 parents aaac785 + 4e090eb commit 324d9b5

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"clean": "rm -rf dist",
1515
"lint": "eslint . --ext .js,.ts && tsc --noEmit",
1616
"prebuild": "npm run clean && npm run lint && mkdir dist",
17-
"build": "tsc && cp src/index.css dist/index.css",
17+
"build": "tsc",
1818
"pretest": "npm run build",
1919
"test": "karma start ./test/karma.config.cjs",
2020
"prepublishOnly": "npm run build",

src/index.css

-4
This file was deleted.

src/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ export default class IncludeFragmentElement extends HTMLElement {
161161
}
162162
}
163163

164+
constructor() {
165+
super()
166+
this.attachShadow({mode: 'open'}).innerHTML = `
167+
<style>
168+
:host {
169+
display: block;
170+
}
171+
</style>
172+
<slot></slot>`
173+
}
174+
164175
connectedCallback(): void {
165176
if (this.src && this.loading === 'eager') {
166177
handleData(this)

0 commit comments

Comments
 (0)