From ce8325855c29c84de02d117183d79bb34aa24082 Mon Sep 17 00:00:00 2001 From: Mattes Mohr Date: Sat, 30 Nov 2024 14:16:12 +0100 Subject: [PATCH] Assign the ismap attribute (#157) * Assign the ismap attribute to the image element --- .../Abstraction/Attributes/BasicAttributes.swift | 16 ++++++++++++---- .../Abstraction/Elements/BodyElements.swift | 6 +++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift index 7d5b4e9a..2b6a0415 100644 --- a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift +++ b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift @@ -1087,14 +1087,22 @@ extension IdentifierAttribute where Self: EmptyNode { } } -/// The protocol provides the element with the ismap handler. +/// A type that provides the `isMap` modifier. @_documentation(visibility: internal) public protocol IsMapAttribute: Attribute { - /// The function represents the html-attribute 'ismap'. + /// Mark an element as a server-side image map. /// - /// ```html - /// + /// It enables the element to send click coordinates to the server, + /// allowing interactions with the element. + /// + /// ```swift + /// Anchor { + /// Image() + /// .source("...png") + /// .isMap() + /// } + /// .reference("https://...") /// ``` func isMap() -> Self } diff --git a/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift b/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift index 4c954f0b..57c139b1 100644 --- a/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift +++ b/Sources/HTMLKit/Abstraction/Elements/BodyElements.swift @@ -15337,7 +15337,7 @@ public struct Image: EmptyNode, HtmlElement, BodyElement, FormElement, FigureEle } } -extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, AlternateAttribute, SourceAttribute, SizesAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute, FetchPriorityAttribute & LoadingAttribute & SourceSetAttribute & DecodingAttribute { +extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, AlternateAttribute, SourceAttribute, SizesAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute, FetchPriorityAttribute & LoadingAttribute & SourceSetAttribute & DecodingAttribute & IsMapAttribute { public func accessKey(_ value: Character) -> Image { return mutate(accesskey: value) @@ -15415,6 +15415,10 @@ extension Image: GlobalAttributes, GlobalEventAttributes, GlobalAriaAttributes, public func id(_ value: String) -> Image { return mutate(id: value) } + + public func isMap() -> Image { + return mutate(ismap: "ismap") + } public func language(_ value: Values.Language) -> Image { return mutate(lang: value.rawValue)