pull/16197/head
Rich Harris 5 months ago
commit 77e0e60af0

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow characters in the supplementary special-purpose plane

@ -1,5 +1,11 @@
# svelte # svelte
## 5.28.2
### Patch Changes
- fix: don't mark selector lists inside `:global` with multiple items as unused ([#15817](https://github.com/sveltejs/svelte/pull/15817))
## 5.28.1 ## 5.28.1
### Patch Changes ### Patch Changes

@ -2,7 +2,7 @@
"name": "svelte", "name": "svelte",
"description": "Cybernetically enhanced web apps", "description": "Cybernetically enhanced web apps",
"license": "MIT", "license": "MIT",
"version": "5.28.1", "version": "5.28.2",
"type": "module", "type": "module",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"engines": { "engines": {

@ -72,6 +72,8 @@ const NUL = 0;
// to replace them ourselves // to replace them ourselves
// //
// Source: http://en.wikipedia.org/wiki/Character_encodings_in_HTML#Illegal_characters // Source: http://en.wikipedia.org/wiki/Character_encodings_in_HTML#Illegal_characters
// Also see: https://en.wikipedia.org/wiki/Plane_(Unicode)
// Also see: https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream
/** @param {number} code */ /** @param {number} code */
function validate_code(code) { function validate_code(code) {
@ -116,5 +118,10 @@ function validate_code(code) {
return code; return code;
} }
// supplementary special-purpose plane 0xe0000 - 0xe07f and 0xe0100 - 0xe01ef
if ((code >= 917504 && code <= 917631) || (code >= 917760 && code <= 917999)) {
return code;
}
return NUL; return NUL;
} }

@ -196,9 +196,12 @@ const visitors = {
next(); next();
}, },
SelectorList(node, { state, next, path }) { SelectorList(node, { state, next, path }) {
const parent = path.at(-1);
// Only add comments if we're not inside a complex selector that itself is unused or a global block // Only add comments if we're not inside a complex selector that itself is unused or a global block
if ( if (
(!is_in_global_block(path) || node.children.length > 1) && (!is_in_global_block(path) ||
(node.children.length > 1 && parent?.type === 'Rule' && parent.metadata.is_global_block)) &&
!path.find((n) => n.type === 'ComplexSelector' && !n.metadata.used) !path.find((n) => n.type === 'ComplexSelector' && !n.metadata.used)
) { ) {
const children = node.children; const children = node.children;
@ -260,7 +263,6 @@ const visitors = {
// if this selector list belongs to a rule, require a specificity bump for the // if this selector list belongs to a rule, require a specificity bump for the
// first scoped selector but only if we're at the top level // first scoped selector but only if we're at the top level
let parent = path.at(-1);
if (parent?.type === 'Rule') { if (parent?.type === 'Rule') {
specificity = { bumped: false }; specificity = { bumped: false };
@ -376,7 +378,6 @@ const visitors = {
}; };
/** /**
*
* @param {Array<AST.CSS.Node>} path * @param {Array<AST.CSS.Node>} path
*/ */
function is_in_global_block(path) { function is_in_global_block(path) {

@ -4,5 +4,5 @@
* The current version, as set in package.json. * The current version, as set in package.json.
* @type {string} * @type {string}
*/ */
export const VERSION = '5.28.1'; export const VERSION = '5.28.2';
export const PUBLIC_VERSION = '5'; export const PUBLIC_VERSION = '5';

@ -7,28 +7,28 @@ export default test({
code: 'css_unused_selector', code: 'css_unused_selector',
message: 'Unused CSS selector ".unused :global"', message: 'Unused CSS selector ".unused :global"',
start: { start: {
line: 69, line: 73,
column: 1, column: 1,
character: 917 character: 964
}, },
end: { end: {
line: 69, line: 73,
column: 16, column: 16,
character: 932 character: 979
} }
}, },
{ {
code: 'css_unused_selector', code: 'css_unused_selector',
message: 'Unused CSS selector "unused :global"', message: 'Unused CSS selector "unused :global"',
start: { start: {
line: 100, line: 104,
column: 29, column: 29,
character: 1223 character: 1270
}, },
end: { end: {
line: 100, line: 104,
column: 43, column: 43,
character: 1237 character: 1284
} }
} }
] ]

@ -3,6 +3,10 @@
.x { .x {
color: green; color: green;
} }
.a, .selector, .list {
color: green;
}
/*}*/ /*}*/
div.svelte-xyz { div.svelte-xyz {

@ -5,6 +5,10 @@
.x { .x {
color: green; color: green;
} }
.a, .selector, .list {
color: green;
}
} }
div :global { div :global {

Loading…
Cancel
Save