Skip to content

Use :host rule instead of :root for @theme layer #15972

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
"@layer theme {
:root {
:host {
--font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
Expand Down
4 changes: 2 additions & 2 deletions packages/@tailwindcss-postcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ test('runs `Once` plugins in the right order', async () => {
)

expect(result.css.trim()).toMatchInlineSnapshot(`
":root {
":host {
--color-red-500: red;
}

Expand All @@ -297,7 +297,7 @@ test('runs `Once` plugins in the right order', async () => {
}"
`)
expect(after).toMatchInlineSnapshot(`
":root {
":host {
--color-red-500: red;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`compiling CSS > \`@tailwind utilities\` is replaced by utilities using the default theme 1`] = `
":root {
":host {
--font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
Expand Down
18 changes: 9 additions & 9 deletions packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`border-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -126,7 +126,7 @@ exports[`border-* 1`] = `
`;

exports[`border-b-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -251,7 +251,7 @@ exports[`border-b-* 1`] = `
`;

exports[`border-e-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -376,7 +376,7 @@ exports[`border-e-* 1`] = `
`;

exports[`border-l-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -501,7 +501,7 @@ exports[`border-l-* 1`] = `
`;

exports[`border-r-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -626,7 +626,7 @@ exports[`border-r-* 1`] = `
`;

exports[`border-s-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -751,7 +751,7 @@ exports[`border-s-* 1`] = `
`;

exports[`border-t-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -876,7 +876,7 @@ exports[`border-t-* 1`] = `
`;

exports[`border-x-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ exports[`border-x-* 1`] = `
`;

exports[`border-y-* 1`] = `
":root {
":host {
--radius-none: 0px;
--radius-full: 9999px;
--radius-sm: .125rem;
Expand Down
36 changes: 18 additions & 18 deletions packages/tailwindcss/src/compat/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('theme callbacks', () => {

expect(compiler.build(['leading-base', 'leading-md', 'leading-xl', 'prose']))
.toMatchInlineSnapshot(`
":root {
":host {
--text-base: 100rem;
--text-md--line-height: 101rem;
}
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('theme overrides order', () => {
})

expect(compiler.build(['bg-red', 'bg-blue'])).toMatchInlineSnapshot(`
":root {
":host {
--color-blue: blue;
}
.bg-blue {
Expand Down Expand Up @@ -477,7 +477,7 @@ describe('theme overrides order', () => {
'hover-bg-slate-600',
]),
).toMatchInlineSnapshot(`
":root {
":host {
--color-slate-100: #000100;
--color-slate-300: #000300;
--color-slate-400: #100400;
Expand Down Expand Up @@ -562,7 +562,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: Potato Sans;
--default-font-feature-settings: normal;
--default-font-variation-settings: normal;
Expand Down Expand Up @@ -601,7 +601,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: Potato Sans;
--default-font-feature-settings: "cv06";
--default-font-variation-settings: normal;
Expand Down Expand Up @@ -641,7 +641,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: Potato Sans;
--default-font-feature-settings: normal;
--default-font-variation-settings: "XHGT" 0.7;
Expand Down Expand Up @@ -684,7 +684,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: Potato Sans;
--default-font-feature-settings: "cv06";
--default-font-variation-settings: "XHGT" 0.7;
Expand Down Expand Up @@ -728,7 +728,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: var(--font-family-sans);
--default-font-feature-settings: var(--font-family-sans--font-feature-settings);
--default-font-variation-settings: var(--font-family-sans--font-variation-settings);
Expand Down Expand Up @@ -768,7 +768,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: Inter, system-ui, sans-serif;
--default-font-feature-settings: normal;
--default-font-variation-settings: normal;
Expand Down Expand Up @@ -807,7 +807,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-sans'])).toMatchInlineSnapshot(`
":root {
":host {
--default-font-family: var(--font-family-sans);
--default-font-feature-settings: var(--font-family-sans--font-feature-settings);
--default-font-variation-settings: var(--font-family-sans--font-variation-settings);
Expand Down Expand Up @@ -841,7 +841,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-mono'])).toMatchInlineSnapshot(`
":root {
":host {
--default-mono-font-family: Potato Mono;
--default-mono-font-feature-settings: normal;
--default-mono-font-variation-settings: normal;
Expand Down Expand Up @@ -880,7 +880,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-mono'])).toMatchInlineSnapshot(`
":root {
":host {
--default-mono-font-family: Potato Mono;
--default-mono-font-feature-settings: "cv06";
--default-mono-font-variation-settings: normal;
Expand Down Expand Up @@ -920,7 +920,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-mono'])).toMatchInlineSnapshot(`
":root {
":host {
--default-mono-font-family: Potato Mono;
--default-mono-font-feature-settings: normal;
--default-mono-font-variation-settings: "XHGT" 0.7;
Expand Down Expand Up @@ -963,7 +963,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-mono'])).toMatchInlineSnapshot(`
":root {
":host {
--default-mono-font-family: Potato Mono;
--default-mono-font-feature-settings: "cv06";
--default-mono-font-variation-settings: "XHGT" 0.7;
Expand Down Expand Up @@ -1007,7 +1007,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-mono'])).toMatchInlineSnapshot(`
":root {
":host {
--default-mono-font-family: var(--font-mono);
--default-mono-font-feature-settings: var(--font-mono--font-feature-settings);
--default-mono-font-variation-settings: var(--font-mono--font-variation-settings);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ describe('default font family compatibility', () => {
})

expect(compiler.build(['font-mono'])).toMatchInlineSnapshot(`
":root {
":host {
--default-mono-font-family: var(--font-family-mono);
--default-mono-font-feature-settings: var(--font-family-mono--font-feature-settings);
--default-mono-font-variation-settings: var(--font-family-mono--font-variation-settings);
Expand Down Expand Up @@ -1179,7 +1179,7 @@ test('merges css breakpoints with js config screens', async () => {

expect(compiler.build(['sm:flex', 'md:flex', 'lg:flex', 'min-sm:max-md:underline']))
.toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-md: 50rem;
--breakpoint-lg: 64rem;
--breakpoint-xl: 80rem;
Expand Down Expand Up @@ -1333,7 +1333,7 @@ test('Prefixes configured in CSS take precedence over those defined in JS config
)

expect(compiler.build(['wat:custom'])).toMatchInlineSnapshot(`
":root {
":host {
--wat-color-red: #f00;
--wat-color-green: #0f0;
--wat-breakpoint-sm: 640px;
Expand Down
16 changes: 8 additions & 8 deletions packages/tailwindcss/src/compat/container-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('creates a custom utility to extend the built-in container', async () => {
})

expect(compiler.build(['container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down Expand Up @@ -96,7 +96,7 @@ test('allows padding to be defined at custom breakpoints', async () => {
})

expect(compiler.build(['container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down Expand Up @@ -164,7 +164,7 @@ test('allows breakpoints to be overwritten', async () => {
})

expect(compiler.build(['container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down Expand Up @@ -237,7 +237,7 @@ test('padding applies to custom `container` screens', async () => {
})

expect(compiler.build(['container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down Expand Up @@ -307,7 +307,7 @@ test("an empty `screen` config will undo all custom media screens and won't appl
})

expect(compiler.build(['container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down Expand Up @@ -379,7 +379,7 @@ test('legacy container component does not interfere with new --container variabl
})

expect(compiler.build(['max-w-sm'])).toMatchInlineSnapshot(`
":root {
":host {
--container-3xs: 16rem;
--container-2xs: 18rem;
--container-xs: 20rem;
Expand Down Expand Up @@ -438,7 +438,7 @@ test('combines custom padding and screen overwrites', async () => {
})

expect(compiler.build(['container', '!container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down Expand Up @@ -557,7 +557,7 @@ test('filters out complex breakpoints', async () => {
})

expect(compiler.build(['container'])).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/compat/legacy-utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test('max-w-screen', async () => {
],
),
).toMatchInlineSnapshot(`
":root {
":host {
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
Expand Down
Loading