def self.merge_attrs(to, from)
from['id'] = Compiler.filter_and_join(from['id'], '_') if from['id']
if to['id'] && from['id']
to['id'] << '_' << from.delete('id').to_s
elsif to['id'] || from['id']
from['id'] ||= to['id']
end
from['class'] = Compiler.filter_and_join(from['class'], ' ') if from['class']
if to['class'] && from['class']
from['class'] = (from['class'].to_s.split(' ') | to['class'].split(' ')).sort.join(' ')
elsif to['class'] || from['class']
from['class'] ||= to['class']
end
from_data = from.delete('data') || {}
to_data = to.delete('data') || {}
from_data = { nil => from_data } unless from_data.is_a?(Hash)
to_data = { nil => to_data } unless to_data.is_a?(Hash)
merged_data = to_data.merge(from_data)
to['data'] = merged_data unless merged_data.empty?
to.merge!(from)
end