class Sass::Tree::PropNode
@see Sass::Tree
A static node representing a CSS property.
def ==(other)
-
(Boolean)
- Whether or not this node and the other object
Parameters:
-
other
(Object
) -- The object to compare with
def ==(other) self.class == other.class && name == other.name && value == other.value && super end
def check!
def check! return unless @options[:property_syntax] && @options[:property_syntax] != @prop_syntax raise Sass::SyntaxError.new( "Illegal property syntax: can't use #{@prop_syntax} syntax when " + ":property_syntax => #{@options[:property_syntax].inspect} is set.") end
def custom_property?
-
(Boolean)
-
def custom_property? name.first.is_a?(String) && name.first.start_with?("--") end
def declaration(opts = {:old => @prop_syntax == :old}, fmt = :sass)
-
fmt
(Symbol
) -- `:scss` or `:sass`. -
opts
({Symbol => Object}
) -- The options hash for the tree.
def declaration(opts = {:old => @prop_syntax == :old}, fmt = :sass) name = self.name.map {|n| n.is_a?(String) ? n : n.to_sass(opts)}.join value = self.value.map {|n| n.is_a?(String) ? n : n.to_sass(opts)}.join value = "(#{value})" if value_needs_parens? if name[0] == ?: raise Sass::SyntaxError.new("The \"#{name}: #{value}\"" + " hack is not allowed in the Sass indented syntax") end # The indented syntax doesn't support newlines in custom property values, # but we can losslessly convert them to spaces instead. value = value.tr("\n", " ") if fmt == :sass old = opts[:old] && fmt == :sass "#{old ? ':' : ''}#{name}#{old ? '' : ':'}#{custom_property? ? '' : ' '}#{value}".rstrip end
def initialize(name, value, prop_syntax)
-
prop_syntax
(Symbol
) -- `:new` if this property uses `a: b`-style syntax, -
value
(Array
) -- See \{#value} -
name
(Array
) -- See \{#name}
def initialize(name, value, prop_syntax) @name = Sass::Util.strip_string_array( Sass::Util.merge_adjacent_strings(name)) @value = Sass::Util.merge_adjacent_strings(value) @value = Sass::Util.strip_string_array(@value) unless custom_property? @tabs = 0 @prop_syntax = prop_syntax super() end
def invisible?
-
(Boolean)
-
def invisible? !custom_property? && resolved_value.empty? end
def pseudo_class_selector_message
-
(String)
- The message
def pseudo_class_selector_message if @prop_syntax == :new || custom_property? || !value.first.is_a?(Sass::Script::Tree::Literal) || !value.first.value.is_a?(Sass::Script::Value::String) || !value.first.value.value.empty? return "" end "\nIf #{declaration.dump} should be a selector, use \"\\#{declaration}\" instead." end
def value_needs_parens?
Returns whether \{#value} neesd parentheses in order to be parsed
def value_needs_parens? return false if custom_property? root = value.first root.is_a?(Sass::Script::Tree::Operation) && root.operator == :div && root.operand1.is_a?(Sass::Script::Tree::Literal) && root.operand1.value.is_a?(Sass::Script::Value::Number) && root.operand1.value.original.nil? && root.operand2.is_a?(Sass::Script::Tree::Literal) && root.operand2.value.is_a?(Sass::Script::Value::Number) && root.operand2.value.original.nil? end