From 64cb8a3ce32b9e2fb881030f0ec636e348408a59 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 2 Nov 2017 14:11:20 -0400 Subject: [PATCH] FIX: Normalizer wasn't working with attributes without values --- lib/html_normalize.rb | 8 +++++--- spec/components/html_normalize_spec.rb | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/html_normalize.rb b/lib/html_normalize.rb index 9b5ebb5d58a..1243a4426a6 100644 --- a/lib/html_normalize.rb +++ b/lib/html_normalize.rb @@ -74,9 +74,11 @@ class HtmlNormalize attrs.each do |a| buffer << " " buffer << a.name - buffer << "='" - buffer << a.value - buffer << "'" + if a.value + buffer << "='" + buffer << a.value + buffer << "'" + end end end diff --git a/spec/components/html_normalize_spec.rb b/spec/components/html_normalize_spec.rb index ec6b4222954..7c75d8a15bd 100644 --- a/spec/components/html_normalize_spec.rb +++ b/spec/components/html_normalize_spec.rb @@ -7,6 +7,10 @@ describe HtmlNormalize do HtmlNormalize.normalize(html) end + it "handles attributes without values" do + expect(n "").to eq("") + end + it "handles self closing tags" do source = <<-HTML