svelte 4.2.11 → 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
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
|
@@ -35503,14 +35503,13 @@ class InlineComponentWrapper extends Wrapper {
|
|
|
35503
35503
|
// statements will become switch_props function body
|
|
35504
35504
|
// rewrite last statement, add props update logic
|
|
35505
35505
|
statements[statements.length - 1] = b$1`
|
|
35506
|
+
for (let #i = 0; #i < ${levels}.length; #i += 1) {
|
|
35507
|
+
${props} = @assign(${props}, ${levels}[#i]);
|
|
35508
|
+
}
|
|
35506
35509
|
if (#dirty !== undefined && ${condition}) {
|
|
35507
|
-
${props} = @get_spread_update(${levels}, [
|
|
35510
|
+
${props} = @assign(${props}, @get_spread_update(${levels}, [
|
|
35508
35511
|
${changes}
|
|
35509
|
-
]);
|
|
35510
|
-
} else {
|
|
35511
|
-
for (let #i = 0; #i < ${levels}.length; #i += 1) {
|
|
35512
|
-
${props} = @assign(${props}, ${levels}[#i]);
|
|
35513
|
-
}
|
|
35512
|
+
]));
|
|
35514
35513
|
}
|
|
35515
35514
|
`;
|
|
35516
35515
|
}
|
|
@@ -42391,14 +42390,17 @@ function apply_selector(blocks, node, to_encapsulate) {
|
|
|
42391
42390
|
}
|
|
42392
42391
|
return false;
|
|
42393
42392
|
} else if (block.combinator.name === '+' || block.combinator.name === '~') {
|
|
42394
|
-
const siblings = get_possible_element_siblings(
|
|
42393
|
+
const [siblings, has_slot_sibling] = get_possible_element_siblings(
|
|
42394
|
+
node,
|
|
42395
|
+
block.combinator.name === '+'
|
|
42396
|
+
);
|
|
42395
42397
|
let has_match = false;
|
|
42396
42398
|
// NOTE: if we have :global(), we couldn't figure out what is selected within `:global` due to the
|
|
42397
42399
|
// css-tree limitation that does not parse the inner selector of :global
|
|
42398
42400
|
// so unless we are sure there will be no sibling to match, we will consider it as matched
|
|
42399
42401
|
const has_global = blocks.some((block) => block.global);
|
|
42400
42402
|
if (has_global) {
|
|
42401
|
-
if (siblings.size === 0 && get_element_parent(node) !== null) {
|
|
42403
|
+
if (siblings.size === 0 && get_element_parent(node) !== null && !has_slot_sibling) {
|
|
42402
42404
|
return false;
|
|
42403
42405
|
}
|
|
42404
42406
|
to_encapsulate.push({ node, block });
|
|
@@ -42642,13 +42644,15 @@ function get_element_parent(node) {
|
|
|
42642
42644
|
* <h1>Heading 1</h1>
|
|
42643
42645
|
* <h2>Heading 2</h2>
|
|
42644
42646
|
* @param {import('../nodes/interfaces.js').INode} node
|
|
42645
|
-
* @returns {import('../nodes/interfaces.js').INode}
|
|
42647
|
+
* @returns {[import('../nodes/interfaces.js').INode, boolean]}
|
|
42646
42648
|
*/
|
|
42647
42649
|
function find_previous_sibling(node) {
|
|
42648
42650
|
/** @type {import('../nodes/interfaces.js').INode} */
|
|
42649
42651
|
let current_node = node;
|
|
42652
|
+
let has_slot_sibling = false;
|
|
42650
42653
|
do {
|
|
42651
42654
|
if (current_node.type === 'Slot') {
|
|
42655
|
+
has_slot_sibling = true;
|
|
42652
42656
|
const slot_children = current_node.children;
|
|
42653
42657
|
if (slot_children.length > 0) {
|
|
42654
42658
|
current_node = slot_children.slice(-1)[0]; // go to its last child first
|
|
@@ -42660,13 +42664,13 @@ function find_previous_sibling(node) {
|
|
|
42660
42664
|
}
|
|
42661
42665
|
current_node = current_node.prev;
|
|
42662
42666
|
} while (current_node && current_node.type === 'Slot');
|
|
42663
|
-
return current_node;
|
|
42667
|
+
return [current_node, has_slot_sibling];
|
|
42664
42668
|
}
|
|
42665
42669
|
|
|
42666
42670
|
/**
|
|
42667
42671
|
* @param {import('../nodes/interfaces.js').INode} node
|
|
42668
42672
|
* @param {boolean} adjacent_only
|
|
42669
|
-
* @returns {Map<import('../nodes/Element.js').default, NodeExistsValue
|
|
42673
|
+
* @returns {[Map<import('../nodes/Element.js').default, NodeExistsValue>, boolean]}
|
|
42670
42674
|
*/
|
|
42671
42675
|
function get_possible_element_siblings(node, adjacent_only) {
|
|
42672
42676
|
/** @type {Map<import('../nodes/Element.js').default, NodeExistsValue>} */
|
|
@@ -42674,7 +42678,10 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42674
42678
|
|
|
42675
42679
|
/** @type {import('../nodes/interfaces.js').INode} */
|
|
42676
42680
|
let prev = node;
|
|
42677
|
-
|
|
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;
|
|
42678
42685
|
if (prev.type === 'Element') {
|
|
42679
42686
|
if (
|
|
42680
42687
|
!prev.attributes.find(
|
|
@@ -42690,7 +42697,7 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42690
42697
|
const possible_last_child = get_possible_last_child(prev, adjacent_only);
|
|
42691
42698
|
add_to_map(possible_last_child, result);
|
|
42692
42699
|
if (adjacent_only && has_definite_elements(possible_last_child)) {
|
|
42693
|
-
return result;
|
|
42700
|
+
return [result, has_slot_sibling];
|
|
42694
42701
|
}
|
|
42695
42702
|
}
|
|
42696
42703
|
}
|
|
@@ -42705,7 +42712,11 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42705
42712
|
parent.type === 'ElseBlock' ||
|
|
42706
42713
|
parent.type === 'AwaitBlock')
|
|
42707
42714
|
) {
|
|
42708
|
-
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;
|
|
42709
42720
|
add_to_map(possible_siblings, result);
|
|
42710
42721
|
if (parent.type === 'EachBlock') {
|
|
42711
42722
|
// first child of each block can select the last child of each block as previous sibling
|
|
@@ -42723,7 +42734,7 @@ function get_possible_element_siblings(node, adjacent_only) {
|
|
|
42723
42734
|
}
|
|
42724
42735
|
}
|
|
42725
42736
|
}
|
|
42726
|
-
return result;
|
|
42737
|
+
return [result, has_slot_sibling];
|
|
42727
42738
|
}
|
|
42728
42739
|
|
|
42729
42740
|
/**
|
|
@@ -43596,7 +43607,7 @@ function is_used_as_reference(node, parent) {
|
|
|
43596
43607
|
* https://svelte.dev/docs/svelte-compiler#svelte-version
|
|
43597
43608
|
* @type {string}
|
|
43598
43609
|
*/
|
|
43599
|
-
const VERSION = '4.2.
|
|
43610
|
+
const VERSION = '4.2.13';
|
|
43600
43611
|
|
|
43601
43612
|
const regex_leading_directory_separator = /^[/\\]/;
|
|
43602
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
|
/**
|
|
@@ -277,14 +277,13 @@ export default class InlineComponentWrapper extends Wrapper {
|
|
|
277
277
|
// statements will become switch_props function body
|
|
278
278
|
// rewrite last statement, add props update logic
|
|
279
279
|
statements[statements.length - 1] = b`
|
|
280
|
+
for (let #i = 0; #i < ${levels}.length; #i += 1) {
|
|
281
|
+
${props} = @assign(${props}, ${levels}[#i]);
|
|
282
|
+
}
|
|
280
283
|
if (#dirty !== undefined && ${condition}) {
|
|
281
|
-
${props} = @get_spread_update(${levels}, [
|
|
284
|
+
${props} = @assign(${props}, @get_spread_update(${levels}, [
|
|
282
285
|
${changes}
|
|
283
|
-
]);
|
|
284
|
-
} else {
|
|
285
|
-
for (let #i = 0; #i < ${levels}.length; #i += 1) {
|
|
286
|
-
${props} = @assign(${props}, ${levels}[#i]);
|
|
287
|
-
}
|
|
286
|
+
]));
|
|
288
287
|
}
|
|
289
288
|
`;
|
|
290
289
|
}
|
package/src/shared/version.js
CHANGED