svelte 4.2.12 → 4.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/compiler.cjs +22 -10
- package/package.json +1 -1
- package/src/compiler/compile/css/Selector.js +21 -9
- package/src/shared/version.js +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Learn more at the [Svelte website](https://svelte.dev), or stop by the [Discord
|
|
|
14
14
|
|
|
15
15
|
You can play around with Svelte in the [tutorial](https://learn.svelte.dev/), [examples](https://svelte.dev/examples), and [REPL](https://svelte.dev/repl).
|
|
16
16
|
|
|
17
|
-
When you're ready to build a full-
|
|
17
|
+
When you're ready to build a full-fledged application, we recommend using [SvelteKit](https://kit.svelte.dev):
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
npm create svelte@latest my-app
|
package/compiler.cjs
CHANGED
|
@@ -42390,14 +42390,17 @@ function apply_selector(blocks, node, to_encapsulate) {
|
|
|
42390
42390
|
}
|
|
42391
42391
|
return false;
|
|
42392
42392
|
} else if (block.combinator.name === '+' || block.combinator.name === '~') {
|
|
42393
|
-
const siblings = get_possible_element_siblings(
|
|
42393
|
+
const [siblings, has_slot_sibling] = get_possible_element_siblings(
|
|
42394
|
+
node,
|
|
42395
|
+
block.combinator.name === '+'
|
|
42396
|
+
);
|
|
42394
42397
|
let has_match = false;
|
|
42395
42398
|
// NOTE: if we have :global(), we couldn't figure out what is selected within `:global` due to the
|
|
42396
42399
|
// css-tree limitation that does not parse the inner selector of :global
|
|
42397
42400
|
// so unless we are sure there will be no sibling to match, we will consider it as matched
|
|
42398
42401
|
const has_global = blocks.some((block) => block.global);
|
|
42399
42402
|
if (has_global) {
|
|
42400
|
-
if (siblings.size === 0 && get_element_parent(node) !== null) {
|
|
42403
|
+
if (siblings.size === 0 && get_element_parent(node) !== null && !has_slot_sibling) {
|
|
42401
42404
|
return false;
|
|
42402
42405
|
}
|
|
42403
42406
|
to_encapsulate.push({ node, block });
|
|
@@ -42641,13 +42644,15 @@ function get_element_parent(node) {
|
|
|
42641
42644
|
* <h1>Heading 1</h1>
|
|
42642
42645
|
* <h2>Heading 2</h2>
|
|
42643
42646
|
* @param {import('../nodes/interfaces.js').INode} node
|
|
42644
|
-
* @returns {import('../nodes/interfaces.js').INode}
|
|
42647
|
+
* @returns {[import('../nodes/interfaces.js').INode, boolean]}
|
|
42645
42648
|
*/
|
|
42646
42649
|
function find_previous_sibling(node) {
|
|
42647
42650
|
/** @type {import('../nodes/interfaces.js').INode} */
|
|
42648
42651
|
let current_node = node;
|
|
42652
|
+
let has_slot_sibling = false;
|
|
42649
42653
|
do {
|
|
42650
42654
|
if (current_node.type === 'Slot') {
|
|
42655
|
+
has_slot_sibling = true;
|
|
42651
42656
|
const slot_children = current_node.children;
|
|
42652
42657
|
if (slot_children.length > 0) {
|
|
42653
42658
|
current_node = slot_children.slice(-1)[0]; // go to its last child first
|
|
@@ -42659,13 +42664,13 @@ function find_previous_sibling(node) {
|
|
|
42659
42664
|
}
|
|
42660
42665
|
current_node = current_node.prev;
|
|
42661
42666
|
} while (current_node && current_node.type === 'Slot');
|
|
42662
|
-
return current_node;
|
|
42667
|
+
return [current_node, has_slot_sibling];
|
|
42663
42668
|
}
|
|
42664
42669
|
|
|
42665
42670
|
/**
|
|
42666
42671
|
* @param {import('../nodes/interfaces.js').INode} node
|
|
42667
42672
|
* @param {boolean} adjacent_only
|
|
42668
|
-
* @returns {Map<import('../nodes/Element.js').default, NodeExistsValue
|
|
42673
|
+
* @returns {[Map<import('../nodes/Element.js').default, NodeExistsValue>, boolean]}
|
|
42669
42674
|
*/
|
|
42670
42675
|
function get_possible_element_siblings(node, adjacent_only) {
|
|
42671
42676
|
/** @type {Map<import('../nodes/Element.js').default, NodeExistsValue>} */
|
|
@@ -42673,7 +42678,10 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42673
42678
|
|
|
42674
42679
|
/** @type {import('../nodes/interfaces.js').INode} */
|
|
42675
42680
|
let prev = node;
|
|
42676
|
-
|
|
42681
|
+
let has_slot_sibling = false;
|
|
42682
|
+
let slot_sibling_found = false;
|
|
42683
|
+
while (([prev, slot_sibling_found] = find_previous_sibling(prev)) && prev) {
|
|
42684
|
+
has_slot_sibling = has_slot_sibling || slot_sibling_found;
|
|
42677
42685
|
if (prev.type === 'Element') {
|
|
42678
42686
|
if (
|
|
42679
42687
|
!prev.attributes.find(
|
|
@@ -42689,7 +42697,7 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42689
42697
|
const possible_last_child = get_possible_last_child(prev, adjacent_only);
|
|
42690
42698
|
add_to_map(possible_last_child, result);
|
|
42691
42699
|
if (adjacent_only && has_definite_elements(possible_last_child)) {
|
|
42692
|
-
return result;
|
|
42700
|
+
return [result, has_slot_sibling];
|
|
42693
42701
|
}
|
|
42694
42702
|
}
|
|
42695
42703
|
}
|
|
@@ -42704,7 +42712,11 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42704
42712
|
parent.type === 'ElseBlock' ||
|
|
42705
42713
|
parent.type === 'AwaitBlock')
|
|
42706
42714
|
) {
|
|
42707
|
-
const possible_siblings = get_possible_element_siblings(
|
|
42715
|
+
const [possible_siblings, slot_sibling_found] = get_possible_element_siblings(
|
|
42716
|
+
parent,
|
|
42717
|
+
adjacent_only
|
|
42718
|
+
);
|
|
42719
|
+
has_slot_sibling = has_slot_sibling || slot_sibling_found;
|
|
42708
42720
|
add_to_map(possible_siblings, result);
|
|
42709
42721
|
if (parent.type === 'EachBlock') {
|
|
42710
42722
|
// first child of each block can select the last child of each block as previous sibling
|
|
@@ -42722,7 +42734,7 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42722
42734
|
}
|
|
42723
42735
|
}
|
|
42724
42736
|
}
|
|
42725
|
-
return result;
|
|
42737
|
+
return [result, has_slot_sibling];
|
|
42726
42738
|
}
|
|
42727
42739
|
|
|
42728
42740
|
/**
|
|
@@ -43595,7 +43607,7 @@ function is_used_as_reference(node, parent) {
|
|
|
43595
43607
|
* https://svelte.dev/docs/svelte-compiler#svelte-version
|
|
43596
43608
|
* @type {string}
|
|
43597
43609
|
*/
|
|
43598
|
-
const VERSION = '4.2.
|
|
43610
|
+
const VERSION = '4.2.13';
|
|
43599
43611
|
|
|
43600
43612
|
const regex_leading_directory_separator = /^[/\\]/;
|
|
43601
43613
|
const regex_starts_with_term_export = /^Export/;
|
package/package.json
CHANGED
|
@@ -291,14 +291,17 @@ function apply_selector(blocks, node, to_encapsulate) {
|
|
|
291
291
|
}
|
|
292
292
|
return false;
|
|
293
293
|
} else if (block.combinator.name === '+' || block.combinator.name === '~') {
|
|
294
|
-
const siblings = get_possible_element_siblings(
|
|
294
|
+
const [siblings, has_slot_sibling] = get_possible_element_siblings(
|
|
295
|
+
node,
|
|
296
|
+
block.combinator.name === '+'
|
|
297
|
+
);
|
|
295
298
|
let has_match = false;
|
|
296
299
|
// NOTE: if we have :global(), we couldn't figure out what is selected within `:global` due to the
|
|
297
300
|
// css-tree limitation that does not parse the inner selector of :global
|
|
298
301
|
// so unless we are sure there will be no sibling to match, we will consider it as matched
|
|
299
302
|
const has_global = blocks.some((block) => block.global);
|
|
300
303
|
if (has_global) {
|
|
301
|
-
if (siblings.size === 0 && get_element_parent(node) !== null) {
|
|
304
|
+
if (siblings.size === 0 && get_element_parent(node) !== null && !has_slot_sibling) {
|
|
302
305
|
return false;
|
|
303
306
|
}
|
|
304
307
|
to_encapsulate.push({ node, block });
|
|
@@ -542,13 +545,15 @@ function get_element_parent(node) {
|
|
|
542
545
|
* <h1>Heading 1</h1>
|
|
543
546
|
* <h2>Heading 2</h2>
|
|
544
547
|
* @param {import('../nodes/interfaces.js').INode} node
|
|
545
|
-
* @returns {import('../nodes/interfaces.js').INode}
|
|
548
|
+
* @returns {[import('../nodes/interfaces.js').INode, boolean]}
|
|
546
549
|
*/
|
|
547
550
|
function find_previous_sibling(node) {
|
|
548
551
|
/** @type {import('../nodes/interfaces.js').INode} */
|
|
549
552
|
let current_node = node;
|
|
553
|
+
let has_slot_sibling = false;
|
|
550
554
|
do {
|
|
551
555
|
if (current_node.type === 'Slot') {
|
|
556
|
+
has_slot_sibling = true;
|
|
552
557
|
const slot_children = current_node.children;
|
|
553
558
|
if (slot_children.length > 0) {
|
|
554
559
|
current_node = slot_children.slice(-1)[0]; // go to its last child first
|
|
@@ -560,13 +565,13 @@ function find_previous_sibling(node) {
|
|
|
560
565
|
}
|
|
561
566
|
current_node = current_node.prev;
|
|
562
567
|
} while (current_node && current_node.type === 'Slot');
|
|
563
|
-
return current_node;
|
|
568
|
+
return [current_node, has_slot_sibling];
|
|
564
569
|
}
|
|
565
570
|
|
|
566
571
|
/**
|
|
567
572
|
* @param {import('../nodes/interfaces.js').INode} node
|
|
568
573
|
* @param {boolean} adjacent_only
|
|
569
|
-
* @returns {Map<import('../nodes/Element.js').default, NodeExistsValue
|
|
574
|
+
* @returns {[Map<import('../nodes/Element.js').default, NodeExistsValue>, boolean]}
|
|
570
575
|
*/
|
|
571
576
|
function get_possible_element_siblings(node, adjacent_only) {
|
|
572
577
|
/** @type {Map<import('../nodes/Element.js').default, NodeExistsValue>} */
|
|
@@ -574,7 +579,10 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
574
579
|
|
|
575
580
|
/** @type {import('../nodes/interfaces.js').INode} */
|
|
576
581
|
let prev = node;
|
|
577
|
-
|
|
582
|
+
let has_slot_sibling = false;
|
|
583
|
+
let slot_sibling_found = false;
|
|
584
|
+
while (([prev, slot_sibling_found] = find_previous_sibling(prev)) && prev) {
|
|
585
|
+
has_slot_sibling = has_slot_sibling || slot_sibling_found;
|
|
578
586
|
if (prev.type === 'Element') {
|
|
579
587
|
if (
|
|
580
588
|
!prev.attributes.find(
|
|
@@ -590,7 +598,7 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
590
598
|
const possible_last_child = get_possible_last_child(prev, adjacent_only);
|
|
591
599
|
add_to_map(possible_last_child, result);
|
|
592
600
|
if (adjacent_only && has_definite_elements(possible_last_child)) {
|
|
593
|
-
return result;
|
|
601
|
+
return [result, has_slot_sibling];
|
|
594
602
|
}
|
|
595
603
|
}
|
|
596
604
|
}
|
|
@@ -605,7 +613,11 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
605
613
|
parent.type === 'ElseBlock' ||
|
|
606
614
|
parent.type === 'AwaitBlock')
|
|
607
615
|
) {
|
|
608
|
-
const possible_siblings = get_possible_element_siblings(
|
|
616
|
+
const [possible_siblings, slot_sibling_found] = get_possible_element_siblings(
|
|
617
|
+
parent,
|
|
618
|
+
adjacent_only
|
|
619
|
+
);
|
|
620
|
+
has_slot_sibling = has_slot_sibling || slot_sibling_found;
|
|
609
621
|
add_to_map(possible_siblings, result);
|
|
610
622
|
if (parent.type === 'EachBlock') {
|
|
611
623
|
// first child of each block can select the last child of each block as previous sibling
|
|
@@ -623,7 +635,7 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
623
635
|
}
|
|
624
636
|
}
|
|
625
637
|
}
|
|
626
|
-
return result;
|
|
638
|
+
return [result, has_slot_sibling];
|
|
627
639
|
}
|
|
628
640
|
|
|
629
641
|
/**
|
package/src/shared/version.js
CHANGED