Skip to content

Commit

Permalink
fix: css combinator implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Dec 23, 2024
1 parent 6a64524 commit b19304f
Show file tree
Hide file tree
Showing 98 changed files with 349 additions and 12 deletions.
6 changes: 6 additions & 0 deletions packages/playground/src/components/Counter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
<br />
<slot></slot>
</div>

<style>
span {
color: #ff3e00;
}
</style>
6 changes: 6 additions & 0 deletions packages/playground/src/components/Counter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ function increment(e: Event) {
<slot />
</div>
</template>

<style scoped>
span {
color: #35eb9a;
}
</style>
4 changes: 4 additions & 0 deletions packages/svelte-template-compiler/src/ir/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export function isIfBlockOnElseBlock(node: SvelteIfBlock): boolean {
return node.type === 'IfBlock' && !!node.elseif
}

export function isSvelteSlot(node: unknown): boolean {
return isObject(node) && 'type' in node && node.type === 'Slot'
}

export function isSvelteBindingDirective(node: unknown): node is SvelteBaseExpressionDirective {
return isObject(node) && 'type' in node && node.type === 'Binding'
}
Expand Down
11 changes: 10 additions & 1 deletion packages/svelte-template-compiler/src/style/csstree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import type {
SelectorList,
StyleSheet,
TypeSelector,
Value
Value,
WhiteSpace
} from 'css-tree'

export function hasChildren(
Expand Down Expand Up @@ -84,3 +85,11 @@ export function hasName(
export function hasProperty(node: CssNode): node is Declaration {
return node.type === 'Declaration' && 'property' in node
}

export function isWhiteSpace(node: CssNode): node is WhiteSpace {
return node.type === 'WhiteSpace'
}

export function isCombinator(node: CssNode): node is Combinator {
return node.type === 'Combinator'
}
Loading

0 comments on commit b19304f

Please sign in to comment.