Skip to content
Merged
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/phases/1-parse/read/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const REGEX_PERCENTAGE = /^\d+(\.\d+)?%/;
const REGEX_NTH_OF =
/^(even|odd|\+?(\d+|\d*n(\s*[+-]\s*\d+)?)|-\d*n(\s*\+\s*\d+))((?=\s*[,)])|\s+of\s+)/;
const REGEX_WHITESPACE_OR_COLON = /[\s:]/;
const REGEX_BRACE_OR_SEMICOLON = /[{;]/;
const REGEX_BRACE_OR_SEMICOLON = /[{;](?=(?:[^']*'[^']*')*[^']*$)/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const REGEX_BRACE_OR_SEMICOLON = /[{;](?=(?:[^']*'[^']*')*[^']*$)/;
const REGEX_BRACE_OR_SEMICOLON = /[{;](?=[^"']*$)/;

I think the extra complexity here isn't needed — just checking that it doesn't end with a quote would be sufficient. Also don't forget the " character.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about testing, I'm starting in this world of contributing to open source now and even don't know how I would write a test for that.
As for the changeset, is there a style guide or other PR that I could use as example ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! The test case for this should be added in parser-modern. You can read more about contributing to Svelte here.

Unfortunately, I can't help you add a test case as I don't have write access to this PR. You can look at similar tests inside parser-modern though to understand how it works. In short, it is a snapshot test, meaning it takes an input and expects a certain output, if the generated output is different than the expected it fails.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@navorite added a changeset and commited your sugestion. as for tests I'm still stucked

const REGEX_LEADING_HYPHEN_OR_DIGIT = /-?\d/;
const REGEX_VALID_IDENTIFIER_CHAR = /[a-zA-Z0-9_-]/;
const REGEX_COMMENT_CLOSE = /\*\//;
Expand Down