lib/csscss/sass_include_extensions.rb in csscss-1.3.0 vs lib/csscss/sass_include_extensions.rb in csscss-1.3.1

- old
+ new

@@ -1,19 +1,20 @@ require "sass" -module Csscss - class SassMixinVisitor < Sass::Tree::Visitors::Base - def self.visit(root) - new.send(:visit, root) - end +Sass::Tree::MixinDefNode.class_eval do + def children + first_child = @children.first - def visit_mixindef(node) - begin_comment = Sass::Tree::CommentNode.new(["/* CSSCSS START MIXIN: #{node.name} */"], :normal) - end_comment = Sass::Tree::CommentNode.new(["/* CSSCSS END MIXIN: #{node.name} */"], :normal) + # not sure why/how we can get here with empty children, but it + # causes issues + unless @children.empty? || (first_child.is_a?(Sass::Tree::CommentNode) && first_child.value.first =~ /CSSCSS START/) + begin_comment = Sass::Tree::CommentNode.new(["/* CSSCSS START MIXIN: #{name} */"], :normal) + end_comment = Sass::Tree::CommentNode.new(["/* CSSCSS END MIXIN: #{name} */"], :normal) begin_comment.options = end_comment.options = {} - - node.children.unshift(begin_comment) - node.children.push(end_comment) + @children.unshift(begin_comment) + @children.push(end_comment) end + + @children end end