Skip to content
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

Add dppx and dpcm units to parser dimensions #889

Merged
merged 3 commits into from
Aug 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/less/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,13 @@ less.Parser = function Parser(env) {
var value, c = input.charCodeAt(i);
if ((c > 57 || c < 45) || c === 47) return;

if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|rem|vw|vh|vm|vmin|ch)?/)) {
if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|dpcm|dppx|rem|vw|vh|vmin|vm|ch)?/)) {
return new(tree.Dimension)(value[1], value[2]);
}
},

//
// A Ratio
// A Ratio
//
// 16/9
//
Expand All @@ -707,7 +707,7 @@ less.Parser = function Parser(env) {

if (value = $(/^(\d+\/\d+)/)) {
return new(tree.Ratio)(value[1]);
}
}
},

//
Expand Down Expand Up @@ -751,13 +751,13 @@ less.Parser = function Parser(env) {
var a, b;

if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;

save();

if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
return new(tree.Shorthand)(a, b);
}

restore();
},

Expand Down Expand Up @@ -1166,18 +1166,18 @@ less.Parser = function Parser(env) {
hasBlock, hasIdentifier;

if (input.charAt(i) !== '@') return;

if (value = $(this['import']) || $(this.media)) {
return value;
}

name = $(/^@[a-z-]+/);

nonVendorSpecificName = name;
if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {
nonVendorSpecificName = "@" + name.slice(name.indexOf('-', 2) + 1);
}

switch(nonVendorSpecificName) {
case "@font-face":
hasBlock = true;
Expand Down Expand Up @@ -1209,11 +1209,11 @@ less.Parser = function Parser(env) {
hasIdentifier = true;
break;
}

if (hasIdentifier) {
name += " " + ($(/^[^{]+/) || '').trim();
}

if (hasBlock)
{
if (rules = $(this.block)) {
Expand Down
5 changes: 5 additions & 0 deletions test/css/media.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,8 @@
}
}
}
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 2/1), (min-resolution: 2dppx), (min-resolution: 128dpcm) {
.b {
background: red;
}
}
6 changes: 6 additions & 0 deletions test/less/media.less
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,9 @@ body {
}
}
}

@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 2/1), (min-resolution: 2dppx), (min-resolution: 128dpcm) {
.b {
background: red;
}
}