aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb8
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/tags/text_area.rb4
4 files changed, 10 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index adc62ec6a9..5f1f08d19c 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -393,9 +393,7 @@ module ActionView
options[:alt] = options.fetch(:alt){ image_alt(src) }
end
- if size = options.delete(:size)
- options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
- end
+ extract_size!(options, :width, :height)
if mouseover = options.delete(:mouseover)
options[:onmouseover] = "this.src='#{path_to_image(mouseover)}'"
@@ -448,9 +446,7 @@ module ActionView
multiple_sources_tag('video', sources) do |options|
options[:poster] = path_to_image(options[:poster]) if options[:poster]
- if size = options.delete(:size)
- options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
- end
+ extract_size!(options, :width, :height)
end
end
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 248cc2f6a3..7cdb09d7d2 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -317,9 +317,7 @@ module ActionView
def text_area_tag(name, content = nil, options = {})
options = options.stringify_keys
- if size = options.delete("size")
- options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
- end
+ extract_size!(options, 'cols', 'rows')
escape = options.delete("escape") { true }
content = ERB::Util.html_escape(content) if escape
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index f7afa48256..1eeff38ab8 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -137,6 +137,12 @@ module ActionView
"<#{name}#{tag_options}>#{PRE_CONTENT_STRINGS[name.to_sym]}#{content}</#{name}>".html_safe
end
+ def extract_size!(options, x_attribute, y_attribute)
+ if size = options.delete(:size)
+ options[x_attribute], options[y_attribute] = size.split("x") if size =~ %r{^\d+x\d+$}
+ end
+ end
+
def tag_options(options, escape = true)
return if options.blank?
attrs = []
diff --git a/actionpack/lib/action_view/helpers/tags/text_area.rb b/actionpack/lib/action_view/helpers/tags/text_area.rb
index f74652c5e7..160f020263 100644
--- a/actionpack/lib/action_view/helpers/tags/text_area.rb
+++ b/actionpack/lib/action_view/helpers/tags/text_area.rb
@@ -6,9 +6,7 @@ module ActionView
options = @options.stringify_keys
add_default_name_and_id(options)
- if size = options.delete("size")
- options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
- end
+ extract_size!(options, 'cols', 'rows')
content_tag("textarea", options.delete('value') || value_before_type_cast(object), options)
end