Skip to content

Commit 4ef36a6

Browse files
fixed iframe attribute allow behavior
1 parent 5209591 commit 4ef36a6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Sources/HTMLKit/HTMLKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public macro i<T: ExpressibleByStringLiteral>(
455455
public macro iframe<T: ExpressibleByStringLiteral>(
456456
attributes: [HTMLElementAttribute] = [],
457457

458-
allow: T? = nil,
458+
allow: [T] = [],
459459
browsingtopics: Bool = false,
460460
credentialless: Bool = false,
461461
csp: T? = nil,

Sources/HTMLKitMacros/HTMLElement.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ private extension HTMLElement {
349349
case "accept", "coords", "exportparts", "imagesizes", "imagesrcset", "sizes", "srcset":
350350
separator = ","
351351
break
352+
case "allow":
353+
separator = ";"
354+
break
352355
default:
353356
separator = " "
354357
break

Tests/HTMLKitTests/ElementTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ extension ElementTests {
209209
}
210210

211211
// MARK: iframe
212+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
212213
@Test func iframe() {
213-
let string:StaticString = #iframe(sandbox: [.allowDownloads, .allowForms])
214+
var string:StaticString = #iframe(sandbox: [.allowDownloads, .allowForms])
214215
#expect(string == "<iframe sandbox=\"allow-downloads allow-forms\"></iframe>")
216+
217+
string = #iframe(allow: ["geolocation", "test"])
218+
#expect(string == "<iframe allow=\"geolocation;test\"></iframe>")
215219
}
216220

217221
// MARK: input

0 commit comments

Comments
 (0)