File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
packages/svelte/src/compiler/phases/2-analyze/css Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -867,15 +867,18 @@ function unquote(str) {
867867 * @returns {Compiler.AST.RegularElement | Compiler.AST.SvelteElement | null }
868868 */
869869function get_element_parent ( node ) {
870- /** @type {Compiler.SvelteNode | null } */
871- let parent = node ;
872- while (
873- // @ts -expect-error TODO figure out a more elegant solution
874- ( parent = parent . parent ) &&
875- parent . type !== 'RegularElement' &&
876- parent . type !== 'SvelteElement'
877- ) ;
878- return parent ?? null ;
870+ let path = node . metadata . path ;
871+ let i = path . length ;
872+
873+ while ( i -- ) {
874+ const parent = path [ i ] ;
875+
876+ if ( parent . type === 'RegularElement' || parent . type === 'SvelteElement' ) {
877+ return parent ;
878+ }
879+ }
880+
881+ return null ;
879882}
880883
881884/**
You can’t perform that action at this time.
0 commit comments