Skip to content

Commit

Permalink
Account for Svelte class bindings at the start of a line (#4187)
Browse files Browse the repository at this point in the history
* add failing svelte syntax test case

* account for svelte class bindings at the start of a line
  • Loading branch information
bradlc committed Apr 30, 2021
1 parent 3843700 commit 44eddad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jit/lib/expandTailwindAtRules.js
Expand Up @@ -15,7 +15,7 @@ const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/
function getDefaultExtractor(fileExtension) {
return function (content) {
if (fileExtension === 'svelte') {
content = content.replace(/\sclass:/g, ' ')
content = content.replace(/(?:^|\s)class:/g, ' ')
}
let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || []
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || []
Expand Down
4 changes: 4 additions & 0 deletions jit/tests/svelte-syntax.test.css
Expand Up @@ -7,6 +7,10 @@
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
}
.bg-red-500 {
--tw-bg-opacity: 1;
background-color: rgba(239, 68, 68, var(--tw-bg-opacity));
}
@media (min-width: 1024px) {
.lg\:hover\:bg-blue-500:hover {
--tw-bg-opacity: 1;
Expand Down
6 changes: 6 additions & 0 deletions jit/tests/svelte-syntax.test.svelte
Expand Up @@ -3,3 +3,9 @@
</script>

<button class:lg:hover:bg-blue-500={current === 'foo'}>Click me</button>

<button
class:bg-red-500={current === 'foo'}
>
Click me
</button>

0 comments on commit 44eddad

Please sign in to comment.