Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for Svelte class bindings at the start of a line #4187

Merged
merged 2 commits into from Apr 30, 2021

Conversation

bradlc
Copy link
Contributor

@bradlc bradlc commented Apr 26, 2021

Fixes #4181

This PR updates the Svelte class binding regular expression so that it catches instances at the start of a line.

Consider the following example:

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

Because the class extractor runs for each trimmed line separately, in this case it runs against class:bg-red-500={current === 'foo'}. The regular expression did not match the class binding because there is no whitespace before it.

The regular expression has been updated to look for either whitespace or the start of the string, which fixes the issue.

@codecov-commenter
Copy link

Codecov Report

Merging #4187 (ce1a0ee) into master (9b1e843) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4187   +/-   ##
=======================================
  Coverage   86.84%   86.84%           
=======================================
  Files         341      341           
  Lines        4836     4836           
  Branches      919      919           
=======================================
  Hits         4200     4200           
  Misses        561      561           
  Partials       75       75           
Impacted Files Coverage Δ
jit/lib/expandTailwindAtRules.js 81.42% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b1e843...ce1a0ee. Read the comment docs.

@adamwathan adamwathan merged commit 44eddad into master Apr 30, 2021
@adamwathan adamwathan deleted the bugfix-svelte-syntax branch April 30, 2021 12:59
@adamwathan
Copy link
Member

Thanks @bradlc!

adamwathan pushed a commit that referenced this pull request May 7, 2021
* add failing svelte syntax test case

* account for svelte class bindings at the start of a line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Optional svelte class not working with line breaks in HTML when using JIT
3 participants