From d12287c1a6d1abfa99021ec7e92f378bb816390c Mon Sep 17 00:00:00 2001 From: "Anantachai Saothong (Manta)" Date: Thu, 18 Jan 2018 20:50:49 +0700 Subject: [PATCH] Fixed using @media with a hash See https://github.com/ThisIsManta/stylus-supremacy/issues/18 --- edge/format.js | 15 ++++++++++----- spec/media/input.styl | 9 ++++++++- spec/media/output.styl | 10 ++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/edge/format.js b/edge/format.js index c7e890f..1b4c01b 100644 --- a/edge/format.js +++ b/edge/format.js @@ -915,11 +915,16 @@ function format(content, options = {}) { } } else if (inputNode instanceof Stylus.nodes.Feature) { - outputBuffer.append(openParen) - outputBuffer.append(travelThroughSegments(inputNode, indentLevel).join('')) - outputBuffer.append(': ') - outputBuffer.append(travel(inputNode, inputNode.expr, indentLevel, true)) - outputBuffer.append(closeParen) + if (inputNode.expr) { + outputBuffer.append(openParen) + outputBuffer.append(travelThroughSegments(inputNode, indentLevel).join('')) + outputBuffer.append(': ') + outputBuffer.append(travel(inputNode, inputNode.expr, indentLevel, true)) + outputBuffer.append(closeParen) + + } else { + outputBuffer.append(travel(inputNode, inputNode.segments[0], indentLevel, true)) + } } else if (inputNode instanceof Stylus.nodes.Supports) { outputBuffer.append(indent + '@supports ') diff --git a/spec/media/input.styl b/spec/media/input.styl index 6848f42..f0438e1 100644 --- a/spec/media/input.styl +++ b/spec/media/input.styl @@ -4,4 +4,11 @@ display none @media only screen and (min-width: 0px) and (max-width: 679px) display none - \ No newline at end of file + +$display-breakpoints = { + md-and-up: 'screen and (min-width: 600px)' +} + +@media $display-breakpoints.md-and-up + .widget + display: none \ No newline at end of file diff --git a/spec/media/output.styl b/spec/media/output.styl index 5dda914..1df83ff 100644 --- a/spec/media/output.styl +++ b/spec/media/output.styl @@ -9,3 +9,13 @@ @media only screen and (min-width: 0px) and (max-width: 679px) { display: none; } + +$display-breakpoints = { + md-and-up: 'screen and (min-width: 600px)' +}; + +@media $display-breakpoints.md-and-up { + .widget { + display: none; + } +} \ No newline at end of file