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
## 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
### Patch Changes

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

@ -72,6 +72,8 @@ const NUL = 0;
// to replace them ourselves
//
// 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 */
function validate_code(code) {
@ -116,5 +118,10 @@ function validate_code(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;
}

@ -196,9 +196,12 @@ const visitors = {
next();
},
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
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)
) {
const children = node.children;
@ -260,7 +263,6 @@ const visitors = {
// 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
let parent = path.at(-1);
if (parent?.type === 'Rule') {
specificity = { bumped: false };
@ -376,7 +378,6 @@ const visitors = {
};
/**
*
* @param {Array<AST.CSS.Node>} path
*/
function is_in_global_block(path) {

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

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

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

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

Loading…
Cancel
Save