Skip to content

Commit 77e0e60

Browse files
committed
merge main
2 parents 734f56c + 1c2fc21 commit 77e0e60

File tree

9 files changed

+40
-13
lines changed

9 files changed

+40
-13
lines changed

.changeset/wild-bulldogs-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow characters in the supplementary special-purpose plane

packages/svelte/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# svelte
22

3+
## 5.28.2
4+
5+
### Patch Changes
6+
7+
- fix: don't mark selector lists inside `:global` with multiple items as unused ([#15817](https://github.com/sveltejs/svelte/pull/15817))
8+
39
## 5.28.1
410

511
### Patch Changes

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.28.1",
5+
"version": "5.28.2",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/compiler/phases/1-parse/utils/html.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ const NUL = 0;
7272
// to replace them ourselves
7373
//
7474
// Source: http://en.wikipedia.org/wiki/Character_encodings_in_HTML#Illegal_characters
75+
// Also see: https://en.wikipedia.org/wiki/Plane_(Unicode)
76+
// Also see: https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream
7577

7678
/** @param {number} code */
7779
function validate_code(code) {
@@ -116,5 +118,10 @@ function validate_code(code) {
116118
return code;
117119
}
118120

121+
// supplementary special-purpose plane 0xe0000 - 0xe07f and 0xe0100 - 0xe01ef
122+
if ((code >= 917504 && code <= 917631) || (code >= 917760 && code <= 917999)) {
123+
return code;
124+
}
125+
119126
return NUL;
120127
}

packages/svelte/src/compiler/phases/3-transform/css/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,12 @@ const visitors = {
196196
next();
197197
},
198198
SelectorList(node, { state, next, path }) {
199+
const parent = path.at(-1);
200+
199201
// Only add comments if we're not inside a complex selector that itself is unused or a global block
200202
if (
201-
(!is_in_global_block(path) || node.children.length > 1) &&
203+
(!is_in_global_block(path) ||
204+
(node.children.length > 1 && parent?.type === 'Rule' && parent.metadata.is_global_block)) &&
202205
!path.find((n) => n.type === 'ComplexSelector' && !n.metadata.used)
203206
) {
204207
const children = node.children;
@@ -260,7 +263,6 @@ const visitors = {
260263

261264
// if this selector list belongs to a rule, require a specificity bump for the
262265
// first scoped selector but only if we're at the top level
263-
let parent = path.at(-1);
264266
if (parent?.type === 'Rule') {
265267
specificity = { bumped: false };
266268

@@ -376,7 +378,6 @@ const visitors = {
376378
};
377379

378380
/**
379-
*
380381
* @param {Array<AST.CSS.Node>} path
381382
*/
382383
function is_in_global_block(path) {

packages/svelte/src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* The current version, as set in package.json.
55
* @type {string}
66
*/
7-
export const VERSION = '5.28.1';
7+
export const VERSION = '5.28.2';
88
export const PUBLIC_VERSION = '5';

packages/svelte/tests/css/samples/global-block/_config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ export default test({
77
code: 'css_unused_selector',
88
message: 'Unused CSS selector ".unused :global"',
99
start: {
10-
line: 69,
10+
line: 73,
1111
column: 1,
12-
character: 917
12+
character: 964
1313
},
1414
end: {
15-
line: 69,
15+
line: 73,
1616
column: 16,
17-
character: 932
17+
character: 979
1818
}
1919
},
2020
{
2121
code: 'css_unused_selector',
2222
message: 'Unused CSS selector "unused :global"',
2323
start: {
24-
line: 100,
24+
line: 104,
2525
column: 29,
26-
character: 1223
26+
character: 1270
2727
},
2828
end: {
29-
line: 100,
29+
line: 104,
3030
column: 43,
31-
character: 1237
31+
character: 1284
3232
}
3333
}
3434
]

packages/svelte/tests/css/samples/global-block/expected.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
.x {
44
color: green;
55
}
6+
7+
.a, .selector, .list {
8+
color: green;
9+
}
610
/*}*/
711

812
div.svelte-xyz {

packages/svelte/tests/css/samples/global-block/input.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
.x {
66
color: green;
77
}
8+
9+
.a, .selector, .list {
10+
color: green;
11+
}
812
}
913
1014
div :global {

0 commit comments

Comments
 (0)