Add a not operator (~) for Sass booleans.
This commit is contained in:
parent
901e1f378d
commit
c2b34ff492
|
@ -30,6 +30,7 @@ module Sass
|
|||
?* => :times,
|
||||
?/ => :div,
|
||||
?% => :mod,
|
||||
?~ => :not,
|
||||
?& => :single_and,
|
||||
?| => :single_or,
|
||||
CONSTANT_CHAR => :const,
|
||||
|
|
|
@ -53,6 +53,10 @@ class Sass::Constant::Literal # :nodoc:
|
|||
to_bool ? self : other
|
||||
end
|
||||
|
||||
def unary_not
|
||||
Sass::Constant::Bool.from_value(!to_bool)
|
||||
end
|
||||
|
||||
def concat(other)
|
||||
Sass::Constant::String.from_value("#{self.to_s} #{other.to_s}")
|
||||
end
|
||||
|
|
|
@ -396,6 +396,16 @@ a
|
|||
f2 = false && true
|
||||
f3 = true && false
|
||||
f4 = false && false
|
||||
SASS
|
||||
assert_equal(<<CSS, render(<<SASS))
|
||||
a {
|
||||
b: true;
|
||||
c: false; }
|
||||
CSS
|
||||
!var = true
|
||||
a
|
||||
b = ~~!var
|
||||
c = ~!var
|
||||
SASS
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue