Skip to content

Parser now correctly parses attributes with whitespace before colon #51

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 1 commit into from
Sep 10, 2013
Merged

Parser now correctly parses attributes with whitespace before colon #51

merged 1 commit into from
Sep 10, 2013

Conversation

KrofDrakula
Copy link
Contributor

For rules such as:

a {
  margin  : auto;
  padding : 0;
}

... that contain whitespace before a colon, the CSS attribute name is extracted with the whitespace instead of trimming it. This breaks the case above, which is valid CSS. The added test case and modified expected result are contained in the pull request, including the trimming in index.js.

This is a fix I need to fix autoprefixer, which depends on this library for parsing CSS files and applying prefixes where applicable.

@ai
Copy link

ai commented Sep 10, 2013

@visionmedia +1

@@ -181,7 +181,7 @@ module.exports = function(css, options){
// prop
var prop = match(/^(\*?[-\/\*\w]+)\s*/);
if (!prop) return;
prop = prop[0];
prop = prop[0].replace(/^\s+|\s+$/, '');
Copy link
Member

Choose a reason for hiding this comment

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

missing /g to apply both

@tj
Copy link
Member

tj commented Sep 10, 2013

LGTM, just that tiny thing I'll fix

tj added a commit that referenced this pull request Sep 10, 2013
Parser now correctly parses attributes with whitespace before colon
@tj tj merged commit 1ad40c0 into reworkcss:master Sep 10, 2013
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