Skip to content

Commit

Permalink
Assign the ismap attribute (#157)
Browse files Browse the repository at this point in the history
* Assign the ismap attribute to the image element
  • Loading branch information
mattesmohr authored Nov 30, 2024
1 parent b83d930 commit ce83258
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 12 additions & 4 deletions Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// <tag ismap />
/// 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
}
Expand Down
6 changes: 5 additions & 1 deletion Sources/HTMLKit/Abstraction/Elements/BodyElements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ce83258

Please sign in to comment.