Skip to content

Commit b81ed57

Browse files
author
Petr Chalupa
committed
Always substitute _ with - in attributes
1 parent 8bc204e commit b81ed57

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/htmless/abstract/abstract_tag.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def open(attributes = nil)
118118
# @param [#to_s] value
119119
def attribute(name, value)
120120
return __send__(name, value) if respond_to?(name)
121-
@output << @_str_space << name.to_s << @_str_eql_quote << CGI.escapeHTML(value.to_s) << @_str_quote
121+
@output << @_str_space << name.to_s.gsub('_', '-') << @_str_eql_quote << CGI.escapeHTML(value.to_s) << @_str_quote
122122
self
123123
end
124124

spec/htmless_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def id;
185185
end
186186

187187
it "#data-secret" do
188+
quick_render { div('a', data_secret: "I do not tell.") }.should == '<div data-secret="I do not tell.">a</div>'
188189
quick_render { div('a').data_secret("I do not tell.") }.should == '<div data-secret="I do not tell.">a</div>'
189190
end
190191

0 commit comments

Comments
 (0)