diff --git a/lib/tip_tap/nodes/image.rb b/lib/tip_tap/nodes/image.rb index 5ed1a11..b8faad9 100644 --- a/lib/tip_tap/nodes/image.rb +++ b/lib/tip_tap/nodes/image.rb @@ -12,7 +12,7 @@ def include_empty_content_in_json? end def to_html - image_tag(src) + image_tag(src, attrs.except("src")) end def src diff --git a/spec/tip_tap/nodes/image_spec.rb b/spec/tip_tap/nodes/image_spec.rb index 602c897..8d73548 100644 --- a/spec/tip_tap/nodes/image_spec.rb +++ b/spec/tip_tap/nodes/image_spec.rb @@ -11,10 +11,18 @@ expect(html).to be_a(String) expect(html).to eq('') end + + it "optionally returns additional attributes" do + node = TipTap::Nodes::Image.new(src: "https://img.companycam.com/abcd1234.jpeg", alt: "Alt text example") + html = node.to_html + + expect(html).to be_a(String) + expect(html).to eq('Alt text example') + end end describe "src" do - it "returns a the src attribute" do + it "returns the src attribute" do node = TipTap::Nodes::Image.new(src: "https://img.companycam.com/abcd1234.jpeg") expect(node.src).to eq("https://img.companycam.com/abcd1234.jpeg") end