mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Add bang to Haml::AttributeBuilder.merge_attributes
because it is destructive operation.
This commit is contained in:
parent
6881e1990f
commit
987b3bdf66
4 changed files with 6 additions and 6 deletions
|
@ -73,7 +73,7 @@ module Haml
|
|||
# @param to [{String => String,Hash}] The attribute hash to merge into
|
||||
# @param from [{String => Object}] The attribute hash to merge from
|
||||
# @return [{String => String,Hash}] `to`, after being merged
|
||||
def merge_attributes(to, from)
|
||||
def merge_attributes!(to, from)
|
||||
from.keys.each do |key|
|
||||
to[key] = merge_value(key, to[key], from[key])
|
||||
end
|
||||
|
|
|
@ -188,9 +188,9 @@ module Haml
|
|||
def attributes(class_id, obj_ref, *attributes_hashes)
|
||||
attributes = class_id
|
||||
attributes_hashes.each do |old|
|
||||
AttributeBuilder.merge_attributes(attributes, Hash[old.map {|k, v| [k.to_s, v]}])
|
||||
AttributeBuilder.merge_attributes!(attributes, Hash[old.map {|k, v| [k.to_s, v]}])
|
||||
end
|
||||
AttributeBuilder.merge_attributes(attributes, parse_object_ref(obj_ref)) if obj_ref
|
||||
AttributeBuilder.merge_attributes!(attributes, parse_object_ref(obj_ref)) if obj_ref
|
||||
AttributeBuilder.build_attributes(
|
||||
html?, @options[:attr_wrapper], @options[:escape_attrs], @options[:hyphenate_data_attrs], attributes)
|
||||
end
|
||||
|
|
|
@ -652,7 +652,7 @@ MESSAGE
|
|||
# skip merging if no ids or classes found in name
|
||||
return name, attributes_hash unless name =~ /^(.+?)?([\.#].*)$/
|
||||
|
||||
return $1 || "div", AttributeBuilder.merge_attributes(
|
||||
return $1 || "div", AttributeBuilder.merge_attributes!(
|
||||
Haml::Parser.parse_class_and_id($2), attributes_hash)
|
||||
end
|
||||
|
||||
|
|
|
@ -401,13 +401,13 @@ module Haml
|
|||
|
||||
if attributes_hashes[:new]
|
||||
static_attributes, attributes_hash = attributes_hashes[:new]
|
||||
AttributeBuilder.merge_attributes(attributes, static_attributes) if static_attributes
|
||||
AttributeBuilder.merge_attributes!(attributes, static_attributes) if static_attributes
|
||||
attributes_list << attributes_hash
|
||||
end
|
||||
|
||||
if attributes_hashes[:old]
|
||||
static_attributes = parse_static_hash(attributes_hashes[:old])
|
||||
AttributeBuilder.merge_attributes(attributes, static_attributes) if static_attributes
|
||||
AttributeBuilder.merge_attributes!(attributes, static_attributes) if static_attributes
|
||||
attributes_list << attributes_hashes[:old] unless static_attributes || @options.suppress_eval
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue