Skip to content

Commit 2db2f60

Browse files
bradlcadamwathan
authored andcommitted
Account for Svelte class bindings at the start of a line (#4187)
* add failing svelte syntax test case * account for svelte class bindings at the start of a line
1 parent 1385fa7 commit 2db2f60

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

jit/lib/expandTailwindAtRules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/
1515
function getDefaultExtractor(fileExtension) {
1616
return function (content) {
1717
if (fileExtension === 'svelte') {
18-
content = content.replace(/\sclass:/g, ' ')
18+
content = content.replace(/(?:^|\s)class:/g, ' ')
1919
}
2020
let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || []
2121
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || []

jit/tests/svelte-syntax.test.css

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
--tw-ring-offset-shadow: 0 0 #0000;
88
--tw-ring-shadow: 0 0 #0000;
99
}
10+
.bg-red-500 {
11+
--tw-bg-opacity: 1;
12+
background-color: rgba(239, 68, 68, var(--tw-bg-opacity));
13+
}
1014
@media (min-width: 1024px) {
1115
.lg\:hover\:bg-blue-500:hover {
1216
--tw-bg-opacity: 1;

jit/tests/svelte-syntax.test.svelte

+6
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
</script>
44

55
<button class:lg:hover:bg-blue-500={current === 'foo'}>Click me</button>
6+
7+
<button
8+
class:bg-red-500={current === 'foo'}
9+
>
10+
Click me
11+
</button>

0 commit comments

Comments
 (0)