Skip to content

Commit

Permalink
fix(#1679): do not print global for styles, but do for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Moore committed Oct 27, 2021
1 parent 2b24793 commit 6c1f5a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/astro/src/runtime/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,15 @@ export async function renderAstroComponent(component: InstanceType<typeof AstroC

function renderElement(name: string, { props: _props, children = '' }: SSRElement) {
// Do not print `hoist`, `lang`, `global`
const { lang: _, global = false, 'data-astro-id': astroId, 'define:vars': defineVars, ...props } = _props;
const { lang: _, 'data-astro-id': astroId, 'define:vars': defineVars, ...props } = _props;
if (defineVars) {
if (name === 'style') {
if (global) {
if (props.global) {
children = defineStyleVars(`:root`, defineVars) + '\n' + children;
} else {
children = defineStyleVars(`.astro-${astroId}`, defineVars) + '\n' + children;
}
delete props.global;
}
if (name === 'script') {
delete props.hoist;
Expand Down

0 comments on commit 6c1f5a9

Please sign in to comment.