Commit 185fc7ab authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix crash when CSS has free-hanging doc-comment.

Treat this case as we do with other such comments in JavaScipt -
by defaulting to property.
parent f4e2f3db
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -27,14 +27,15 @@ module JsDuck
      @docs
    end

    # <code-block> := <mixin-declaration> | <var-declaration> | <nop>
    # <code-block> := <mixin-declaration> | <var-declaration> | <property>
    def code_block
      if look("@mixin")
        mixin_declaration
      elsif look(:var, ":")
        var_declaration
      else
        {:tagname => :nop}
        # Default to property like in JsParser.
        {:tagname => :property}
      end
    end

+31 −0
Original line number Diff line number Diff line
@@ -259,5 +259,36 @@ describe JsDuck::Aggregator do
    end
  end

  describe "CSS doc-comment followed by CSS selector" do
    before do
      @doc = parse(<<-EOCSS)[0]
        /**
         * Some comment.
         */
        .highlight {
            font-weight: bold;
        }
      EOCSS
    end

    it "gets detected as property" do
      @doc[:tagname].should == :property
    end
  end

  describe "CSS doc-comment followed by nothing" do
    before do
      @doc = parse(<<-EOCSS)[0]
        /**
         * Some comment.
         */
      EOCSS
    end

    it "gets detected as property" do
      @doc[:tagname].should == :property
    end
  end

end