Skip to content

Fix #90 - whitespace between mixin and !important is optional #91

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

Merged
merged 4 commits into from
Oct 2, 2017
Merged

Fix #90 - whitespace between mixin and !important is optional #91

merged 4 commits into from
Oct 2, 2017

Conversation

orottier
Copy link
Contributor

Fixes #90

Please check one:

  • New tests created for this change
  • Tests updated for this change

This PR:

  • Adds new API
  • Extends existing API, backwards-compatible
  • Introduces a breaking change
  • Fixes a bug

Hope this looks good to you, I'm no JS nor parser expert

@@ -116,7 +116,7 @@ export default class LessParser extends Parser {

if (node.selector.indexOf('!important') >= 0) {
node.important = true;
node.selector = node.selector.replace(/\s!important/, '');
node.selector = node.selector.replace(/\s*!important/, '');
Copy link
Owner

Choose a reason for hiding this comment

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

shouldn't this regex be /(\s+)?!important/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's equivalent, no? We can also use /\s?!important/ but I though it would make sense to eat as much whitespace as possible here

@@ -114,9 +114,9 @@ export default class LessParser extends Parser {
// eslint-disable-next-line
delete this.current.nodes;

if (node.selector.indexOf('!important') >= 0) {
if (node.selector.match(/!important/i)) {
Copy link

Choose a reason for hiding this comment

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

should be .test as you don't care about the result

Copy link
Owner

Choose a reason for hiding this comment

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

good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

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.

3 participants