Skip to content

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

Merged
adamwathan merged 2 commits into
masterfrom
bugfix-svelte-syntax
Apr 30, 2021
Merged

Account for Svelte class bindings at the start of a line#4187
adamwathan merged 2 commits into
masterfrom
bugfix-svelte-syntax

Conversation

@bradlc

@bradlc bradlc commented Apr 26, 2021

Copy link
Copy Markdown
Contributor

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

codecov-commenter commented Apr 26, 2021

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.84%. Comparing base (9b1e843) to head (ce1a0ee).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           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           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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
Copy Markdown
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