Skip to content

Commit

Permalink
fix bug from less.js 578
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Feb 20, 2012
1 parent e37cfc6 commit eccaedb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/dotless.Core/Parser/Parsers.cs
Expand Up @@ -1113,31 +1113,43 @@ public Expression MediaFeature(Parser parser)

GatherComments(parser);

memo = Remember(parser);

var entity = Entity(parser);

if (parser.Tokenizer.Match(')'))
if (!entity || !parser.Tokenizer.Match(')'))
{
if (!entity)
Recall(parser, memo);

// match "3/2" for instance
var unrecognised = parser.Tokenizer.Match(@"[^\){]+");
if (unrecognised)
{
return null;
entity = NodeProvider.TextNode(unrecognised.Value, parser.Tokenizer.Location.Index);
}

entity.PreComments = PullComments();
entity.PostComments = GatherAndPullComments(parser);
if (!unrecognised || !parser.Tokenizer.Match(')'))
throw new ParsingException("missing closing bracket for media feature", index);
}

if (!string.IsNullOrEmpty(property))
{
var rule = NodeProvider.Rule(property, entity, index);
rule.IsSemiColonRequired = false;
features.Add(NodeProvider.Paren(rule, index));
}
else
{
features.Add(NodeProvider.Paren(entity, index));
}
if (!entity)
{
return null;
}

entity.PreComments = PullComments();
entity.PostComments = GatherAndPullComments(parser);

if (!string.IsNullOrEmpty(property))
{
var rule = NodeProvider.Rule(property, entity, index);
rule.IsSemiColonRequired = false;
features.Add(NodeProvider.Paren(rule, index));
}
else
return null;
{
features.Add(NodeProvider.Paren(entity, index));
}
}
else
{
Expand Down
28 changes: 28 additions & 0 deletions src/dotless.Test/Specs/Css3Fixture.cs
Expand Up @@ -185,6 +185,34 @@ public void VariablesInMediaDirective()
AssertLess(input, expected);
}

[Test]
public void MediaDirectiveWithDecimal()
{
var input = @"
@media only screen and (min--moz-device-pixel-ratio: 1.5) {
body {
max-width: 480px;
}
}
";

AssertLessUnchanged(input);
}

[Test]
public void MediaDirectiveWithSlash()
{
var input = @"
@media only screen and (-o-min-device-pixel-ratio: 3/2) {
body {
max-width: 480px;
}
}
";

AssertLessUnchanged(input);
}

[Test]
public void SupportMozDocument()
{
Expand Down

0 comments on commit eccaedb

Please sign in to comment.