Skip to content

chore: minor css-prune.js tweaks #14457

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

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
22 changes: 9 additions & 13 deletions packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,12 @@ function get_relative_selectors(node) {

// nesting could be inside pseudo classes like :is, :has or :where
for (let selector of selectors) {
walk(
selector,
{},
{
// @ts-ignore
NestingSelector() {
has_explicit_nesting_selector = true;
}
walk(selector, null, {
// @ts-ignore
NestingSelector() {
has_explicit_nesting_selector = true;
}
);
});
// if we found one we can break from the others
if (has_explicit_nesting_selector) break;
}
Expand Down Expand Up @@ -881,17 +877,17 @@ function get_element_parent(node) {
}

/**
* @param {Compiler.AST.RegularElement | Compiler.AST.SvelteElement} element
* @param {Compiler.AST.RegularElement | Compiler.AST.SvelteElement} node
* @param {boolean} adjacent_only
* @returns {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.SlotElement | Compiler.AST.RenderTag, NodeExistsValue>}
*/
function get_possible_element_siblings(element, adjacent_only) {
function get_possible_element_siblings(node, adjacent_only) {
/** @type {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.SlotElement | Compiler.AST.RenderTag, NodeExistsValue>} */
const result = new Map();
const path = element.metadata.path;
const path = node.metadata.path;

/** @type {Compiler.SvelteNode} */
let current = element;
let current = node;

let i = path.length;

Expand Down