Skip to content
Permalink
Browse files

Merge pull request #26133 from smellsblue/dont-fail-on-non-string

Ensure values are strings before calling gsub
  • Loading branch information
rafaelfranca committed Aug 12, 2016
1 parent 1b2415f commit d40e5f0033329f8269c97d9480749a92817a2968
@@ -187,7 +187,7 @@ def tag_option(key, value, escape)
if value.is_a?(Array)
value = escape ? safe_join(value, " ".freeze) : value.join(" ".freeze)
else
value = escape ? ERB::Util.unwrapped_html_escape(value) : value
value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s
end
%(#{key}="#{value.gsub(/"/, '"'.freeze)}")
end
@@ -29,6 +29,14 @@ def test_tag_options_accepts_blank_option
assert_equal "<p included=\"\" />", tag("p", :included => '')
end

def test_tag_options_accepts_symbol_option_when_not_escaping
assert_equal "<p value=\"symbol\" />", tag("p", { value: :symbol }, false, false)
end

def test_tag_options_accepts_integer_option_when_not_escaping
assert_equal "<p value=\"42\" />", tag("p", { value: 42 }, false, false)
end

def test_tag_options_converts_boolean_option
assert_dom_equal '<p disabled="disabled" itemscope="itemscope" multiple="multiple" readonly="readonly" allowfullscreen="allowfullscreen" seamless="seamless" typemustmatch="typemustmatch" sortable="sortable" default="default" inert="inert" truespeed="truespeed" />',
tag("p", :disabled => true, :itemscope => true, :multiple => true, :readonly => true, :allowfullscreen => true, :seamless => true, :typemustmatch => true, :sortable => true, :default => true, :inert => true, :truespeed => true)

0 comments on commit d40e5f0

Please sign in to comment.
You can’t perform that action at this time.