fix: applying :global for +,~ sibling combinator when slots are present. fixes #9274 by kelvinsjk · Pull Request #9282 · sveltejs/svelte (original) (raw)

fixes #9274

For the following,

<div>
  <slot/>
  <span>xxx</span>
</div>

the style :global(p) + span could be applied because the slot could contain the required p element.

The current code did not apply the style because siblings.size===0 during compilation. To fix it, the existing find_previous_sibling and get_possible_element_siblings functions were modified to also return whether a sibling slot has been found. We only flag a css selector as inapplicable if, in addition to the existing checks on sibling size and parent, if there are no previous sibling that are slots found.

Svelte compiler rewrite

Please note that the Svelte codebase is currently being rewritten. Thus, it's best to hold off on new features or refactorings for the time being.

Before submitting the PR, please make sure you do the following

Tests and linting