Skip to content

Commit 2bd2705

Browse files
bug fix: the key could still be wrapped in the "`" character when rendering under certain conditions
1 parent 0e7a3bf commit 2bd2705

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/HTMLKitUtilityMacros/HTMLElements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ enum HTMLElements : DeclarationMacro {
172172
} else if value_type == "String" || value_type == "Int" || value_type == "Float" || value_type == "Double" {
173173
attributes_func += "\n"
174174
let value:String = value_type == "String" ? key : "String(describing: \(key))"
175-
attributes_func += #"if let \#(key) { items.append("\#(key)=\\\"" + \#(value) + "\\\"") }"#
175+
attributes_func += #"if let \#(key) { items.append("\#(key_literal)=\\\"" + \#(value) + "\\\"") }"#
176176
attributes_func += "\n"
177177
} else {
178178
attributes_func += "\n"

Tests/HTMLKitTests/ElementTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ extension ElementTests {
253253
#expect(string == "<input accept=\".docx,.json\">")
254254
}
255255

256+
// MARK: label
257+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
258+
@Test func _label() {
259+
let string:StaticString = #html(label(for: "what_the", "skrrt"))
260+
#expect(string == "<label for=\"what_the\">skrrt</label>")
261+
}
262+
256263
// MARK: link
257264
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
258265
@Test func _link() {

0 commit comments

Comments
 (0)