File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ def build_attribute_value_node(tokens)
191191 :attribute_unquoted_value ,
192192 )
193193
194- build_node ( :attribute_value , children )
194+ build_node ( :attribute_value , children ) if children . any?
195195 end
196196
197197 def build_text_node ( tokens )
Original file line number Diff line number Diff line change @@ -248,6 +248,37 @@ class ParserTest < ActiveSupport::TestCase
248248 tree . ast
249249 end
250250
251+ test "consumes tag attributes without value" do
252+ tree = Parser . new ( buffer ( "<div foo=>bar</div>" ) )
253+ assert_equal s (
254+ :document ,
255+ s (
256+ :tag ,
257+ nil ,
258+ s ( :tag_name , "div" ) ,
259+ s (
260+ :tag_attributes ,
261+ s (
262+ :attribute ,
263+ s ( :attribute_name , "foo" ) ,
264+ s ( :equal ) ,
265+ nil ,
266+ ) ,
267+ ) ,
268+ nil ,
269+ ) ,
270+ s ( :text , "bar" ) ,
271+ s (
272+ :tag ,
273+ s ( :solidus ) ,
274+ s ( :tag_name , "div" ) ,
275+ nil ,
276+ nil ,
277+ ) ,
278+ ) ,
279+ tree . ast
280+ end
281+
251282 test "consume tag attributes nodes interpolation in name and value" do
252283 tree = Parser . new ( buffer ( "<div data-<%= foo %>=\" some <%= value %> foo\" >" ) )
253284 assert_equal s (
You can’t perform that action at this time.
0 commit comments