@@ -8,7 +8,6 @@ import { get_attribute_chunks, is_text_attribute } from '../../../utils/ast.js';
88/**
99 * @typedef {{
1010 * element: Compiler.AST.RegularElement | Compiler.AST.SvelteElement;
11- * from_render_tag: boolean;
1211 * }} State
1312 */
1413/** @typedef {NODE_PROBABLY_EXISTS | NODE_DEFINITELY_EXISTS } NodeExistsValue */
@@ -53,17 +52,10 @@ const nesting_selector = {
5352/**
5453 *
5554 * @param {Compiler.Css.StyleSheet } stylesheet
56- * @param {Compiler.AST.RegularElement | Compiler.AST.SvelteElement | Compiler.AST.RenderTag } element
55+ * @param {Compiler.AST.RegularElement | Compiler.AST.SvelteElement } element
5756 */
5857export function prune ( stylesheet , element ) {
59- if ( element . type === 'RenderTag' ) {
60- const parent = get_element_parent ( element ) ;
61- if ( ! parent ) return ;
62-
63- walk ( stylesheet , { element : parent , from_render_tag : true } , visitors ) ;
64- } else {
65- walk ( stylesheet , { element, from_render_tag : false } , visitors ) ;
66- }
58+ walk ( stylesheet , { element } , visitors ) ;
6759}
6860
6961/** @type {Visitors<Compiler.Css.Node, State> } */
@@ -77,46 +69,16 @@ const visitors = {
7769 } ,
7870 ComplexSelector ( node , context ) {
7971 const selectors = get_relative_selectors ( node ) ;
80- const inner = selectors [ selectors . length - 1 ] ;
81-
82- if ( context . state . from_render_tag ) {
83- // We're searching for a match that crosses a render tag boundary. That means we have to both traverse up
84- // the element tree (to see if we find an entry point) but also remove selectors from the end (assuming
85- // they are part of the render tag we don't see). We do all possible combinations of both until we find a match.
86- /** @type {Compiler.AST.RegularElement | Compiler.AST.SvelteElement | null } */
87- let element = context . state . element ;
8872
89- while ( element ) {
90- const selectors_to_check = selectors . slice ( ) ;
91-
92- while ( selectors_to_check . length > 0 ) {
93- selectors_to_check . pop ( ) ;
94-
95- if (
96- apply_selector (
97- selectors_to_check ,
98- /** @type {Compiler.Css.Rule } */ ( node . metadata . rule ) ,
99- element ,
100- context . state
101- )
102- ) {
103- mark ( inner , element ) ;
104- node . metadata . used = true ;
105- return ;
106- }
107- }
108-
109- element = get_element_parent ( element ) ;
110- }
111- } else if (
73+ if (
11274 apply_selector (
11375 selectors ,
11476 /** @type {Compiler.Css.Rule } */ ( node . metadata . rule ) ,
11577 context . state . element ,
11678 context . state
11779 )
11880 ) {
119- mark ( inner , context . state . element ) ;
81+ mark ( selectors [ selectors . length - 1 ] , context . state . element ) ;
12082 node . metadata . used = true ;
12183 }
12284
0 commit comments