Skip to content

Commit 4f35635

Browse files
relaxed required value labels for data and event attributes
1 parent fa03889 commit 4f35635

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/HTMLKitUtilities/HTMLKitUtilities.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public enum HTMLElementAttribute : Hashable {
5151
case autofocus(Bool = false)
5252
case `class`([String] = [])
5353
case contenteditable(Extra.contenteditable? = nil)
54-
case data(id: String, value: String? = nil)
54+
case data(_ id: String, _ value: String? = nil)
5555
case dir(Extra.dir? = nil)
5656
case draggable(Extra.draggable? = nil)
5757
case enterkeyhint(Extra.enterkeyhint? = nil)
@@ -81,7 +81,7 @@ public enum HTMLElementAttribute : Hashable {
8181
case writingsuggestions(Extra.writingsuggestions? = nil)
8282

8383
@available(*, deprecated, message: "\nInline event handlers are an outdated way to handle events. General consensus considers this \"bad practice\" and you shouldn't mix your HTML and JavaScript.\n\nThis will never be removed and remains deprecated to encourage use of other techniques.\n\nLearn more at https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#inline_event_handlers_—_dont_use_these.")
84-
case event(Extra.event, value: String? = nil)
84+
case event(Extra.event, _ value: String? = nil)
8585
}
8686
public extension HTMLElementAttribute {
8787
enum Extra {

Tests/HTMLKitTests/HTMLKitTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ extension HTMLKitTests {
110110
]) == "<script>bro</script>")*/
111111
}
112112
@Test func test_events() {
113-
#expect(#div(attributes: [.event(.click, value: "doThing()"), .event(.change, value: "doAnotherThing()")], []) == "<div onclick=\"doThing()\" onchange=\"doAnotherThing()\"></div>")
113+
#expect(#div(attributes: [.event(.click, "doThing()"), .event(.change, "doAnotherThing()")], []) == "<div onclick=\"doThing()\" onchange=\"doAnotherThing()\"></div>")
114114
}
115115
}
116116

117117
extension HTMLKitTests {
118118
@Test func test_attribute_data() {
119-
#expect(#div(attributes: [.data(id: "id", value: "5")]) == "<div data-id=\"5\"></div>")
119+
#expect(#div(attributes: [.data("id", "5")]) == "<div data-id=\"5\"></div>")
120120
}
121121
}
122122

0 commit comments

Comments
 (0)