pull/18779/merge
Bao Nguyen 24 hours ago committed by GitHub
commit bf01b84a2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: align CSS attribute selector case-sensitivity with the HTML spec

@ -23,47 +23,56 @@ const whitelist_attribute_selector = new Map([
]);
/**
* HTML attributes whose enumerated values are case-insensitive per the HTML spec.
* CSS attribute selectors match these values case-insensitively in HTML documents.
* Attribute values that CSS attribute selectors match ASCII case-insensitively in HTML documents.
* @see {@link https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors HTML spec}
*/
const case_insensitive_attributes = new Set([
'accept',
'accept-charset',
'autocapitalize',
'autocomplete',
'behavior',
'align',
'alink',
'axis',
'bgcolor',
'charset',
'crossorigin',
'decoding',
'checked',
'clear',
'codetype',
'color',
'compact',
'declare',
'defer',
'dir',
'direction',
'draggable',
'disabled',
'enctype',
'enterkeyhint',
'fetchpriority',
'formenctype',
'formmethod',
'formtarget',
'hidden',
'face',
'frame',
'hreflang',
'http-equiv',
'inputmode',
'kind',
'loading',
'lang',
'language',
'link',
'media',
'method',
'preload',
'referrerpolicy',
'multiple',
'nohref',
'noresize',
'noshade',
'nowrap',
'readonly',
'rel',
'rev',
'role',
'rules',
'scope',
'scrolling',
'selected',
'shape',
'spellcheck',
'target',
'translate',
'text',
'type',
'valign',
'wrap'
'valuetype',
'vlink'
]);
/** @type {Compiler.AST.CSS.Combinator} */

@ -0,0 +1,21 @@
import { test } from '../../test';
export default test({
warnings: [
{
filename: 'SvelteComponent.svelte',
code: 'css_unused_selector',
message: 'Unused CSS selector "input[autocomplete="on"]"',
start: {
character: 178,
column: 1,
line: 16
},
end: {
character: 202,
column: 25,
line: 16
}
}
]
});

@ -0,0 +1,11 @@
div[lang="en"].svelte-xyz {
color: red;
}
a[hreflang="en"].svelte-xyz {
color: blue;
}
/* (unused) input[autocomplete="on"] {
color: green;
}*/

@ -0,0 +1 @@
<div class="svelte-xyz" lang="EN">Hello</div> <a class="svelte-xyz" hreflang="EN" href="/">World</a> <input autocomplete="ON" />

@ -0,0 +1,19 @@
<div lang="EN">Hello</div>
<a hreflang="EN" href="/">World</a>
<input autocomplete="ON" />
<style>
div[lang="en"] {
color: red;
}
a[hreflang="en"] {
color: blue;
}
input[autocomplete="on"] {
color: green;
}
</style>
Loading…
Cancel
Save