Skip to content

Commit 12b608c

Browse files
authored
Pass attributes for base-64 images (#8)
* Pass attributes for base-64 images * Test
1 parent e6952b9 commit 12b608c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/Html/Elements.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ public func img(src: String, alt: String, _ attribs: [Attribute<Tag.Img>] = [])
870870
public func img(base64: String, type: MediaType, alt: String, _ attribs: [Attribute<Tag.Img>])
871871
-> Node {
872872

873-
return img(src: "data:\(type.description);base64,\(base64)", alt: alt)
873+
return img(src: "data:\(type.description);base64,\(base64)", alt: alt, attribs)
874874
}
875875

876876
/// The `<input>` element represents a typed data field, usually with a form control to allow the user to edit the data.

Tests/HtmlTests/ElementsTests.swift

+7
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ final class ElementsTests: XCTestCase {
205205
""",
206206
render(doc)
207207
)
208+
209+
XCTAssertEqual(
210+
"""
211+
<img src="data:image/png;base64,ZnVuY3Rpb25z" alt class="fun">
212+
""",
213+
render(img(base64: "ZnVuY3Rpb25z", type: .image(.png), alt: "", [Html.class("fun")]))
214+
)
208215
}
209216
}
210217

0 commit comments

Comments
 (0)