Skip to content
Browse files

Separate CSS tokens with spaces in default values.

Not the prettiest solution, but at least it results in correct code
(unlike the previous concatenation without spaces).
  • Loading branch information...
1 parent 8383bde commit 1045808af2e24387f316b69bf50a428658a623a4 @nene nene committed May 31, 2012
Showing with 50 additions and 2 deletions.
  1. +1 −1 lib/jsduck/css_parser.rb
  2. +49 −1 spec/aggregator_css_spec.rb
View
2 lib/jsduck/css_parser.rb
@@ -57,7 +57,7 @@ def var_declaration
:type => :css_var,
:name => name,
:value => {
- :default => value_list.map {|v| v[:value] }.join(""),
+ :default => value_list.map {|v| v[:value] }.join(" "),
:type => value_type(value_list),
}
}
View
50 spec/aggregator_css_spec.rb
@@ -94,7 +94,7 @@ def parse(string)
before do
@doc = parse(<<-EOCSS)[0]
/** */
- $button-height: 25px !default;
+ $foo: 25px !default;
EOCSS
end
@@ -109,6 +109,54 @@ def parse(string)
end
end
+ describe "$var-name: followed by multiple values" do
+ before do
+ @doc = parse(<<-EOCSS)[0]
+ /** */
+ $foo: 25px 0 1em 0;
+ EOCSS
+ end
+
+ it "detects variable type by first value" do
+ @doc[:type].should == "length"
+ end
+ it "detects variable default value" do
+ @doc[:default].should == "25px 0 1em 0"
+ end
+ end
+
+ describe "$var-name: followed by comma-separated values" do
+ before do
+ @doc = parse(<<-EOCSS)[0]
+ /** */
+ $foo: "Arial", "Verdana", sans-serif;
+ EOCSS
+ end
+
+ it "detects variable type by first value" do
+ @doc[:type].should == "string"
+ end
+ it "detects variable default value" do
+ @doc[:default].should == '"Arial" , "Verdana" , sans-serif'
+ end
+ end
+
+ describe "$var-name: followed by unknown function" do
+ before do
+ @doc = parse(<<-EOCSS)[0]
+ /** */
+ $foo: myfunc(1, 2);
+ EOCSS
+ end
+
+ it "doesn't detect variable type" do
+ @doc[:type].should == "Object"
+ end
+ it "detects variable default value" do
+ @doc[:default].should == 'myfunc ( 1 , 2 )'
+ end
+ end
+
def detect_type(value)
return parse(<<-EOCSS)[0][:type]
/** */

0 comments on commit 1045808

Please sign in to comment.
Something went wrong with that request. Please try again.