1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Don't duplicate the same classes

This commit is contained in:
Takashi Kokubun 2015-06-14 02:17:39 +09:00
parent 4c9fa25e07
commit 8bf4a92907
2 changed files with 3 additions and 1 deletions

View file

@ -62,7 +62,7 @@ module Hamlit
when :id
result[key] = [base[key], target[key]].compact.join('_')
when :class
result[key] = [base[key], target[key]].flatten.compact.map(&:to_s).sort.join(' ')
result[key] = [base[key], target[key]].flatten.compact.map(&:to_s).sort.uniq.join(' ')
end
else
result[key] = base[key].nil? ? target[key] : base[key]

View file

@ -124,9 +124,11 @@ describe Hamlit::Engine do
it 'joins attribute class and element class' do
assert_render(<<-HAML, <<-HTML, compatible_only: :haml)
.foo{ class: ['bar'] }
.foo{ class: ['bar', 'foo'] }
.foo{ class: ['bar', nil] }
.foo{ class: ['bar', 'baz'] }
HAML
<div class='bar foo'></div>
<div class='bar foo'></div>
<div class='bar foo'></div>
<div class='bar baz foo'></div>