Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shadow-dom): add preflights and safelist #1110

Merged
merged 1 commit into from Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/vite-lit/src/my-element.ts
Expand Up @@ -46,6 +46,12 @@ export class MyElement extends LitElement {
<br />
${this.span ? html` <div class="bg-red-400">BG Color should change</div>` : html` <div>BG Color should change</div>`}
<br />
<br />
<button class="shadow-2xl bg-white p-4 rounded-lg border-none" part="button">
prefligths: shadow-2xl
</button>
<br />
<br />
<button class="bg-red-100" @click=${this._onClick} part="button">
Click Count: ${this.count}
</button>
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/modes/shadow-dom.ts
Expand Up @@ -48,7 +48,10 @@ export function ShadowDomModuleModePlugin({ uno }: UnocssPluginContext): Plugin
return code

// eslint-disable-next-line prefer-const
let { css, matched } = await uno.generate(code, { preflights: false })
let { css, matched } = await uno.generate(code, {
preflights: true,
safelist: true,
})

if (css && matched) {
// filter only parts from the result reported from the generator
Expand Down