From bd341c54010714a609e8a0527b8a22b10e507448 Mon Sep 17 00:00:00 2001 From: Mattes Mohr Date: Sun, 3 Jul 2022 18:39:30 +0200 Subject: [PATCH] Add support for the event attributes (#89) * Add enumerations of events * Add event handlers to support the event attributes The global event handlers are summed up in the typealias globaleventattributes, wich conforms to the most html elements. The body element is the only element, wich includes a different set of event handlers. * Add tests for the event handlers * Add comments --- .../External/Attributes/EventAttributes.swift | 2095 +---------------- .../External/Elements/BasicElements.swift | 22 +- .../External/Elements/BodyElements.swift | 1654 ++++++++++++- .../Elements/DefinitionElements.swift | 44 +- .../External/Elements/FigureElements.swift | 22 +- .../External/Elements/FormElements.swift | 138 +- .../External/Elements/HeadElements.swift | 126 +- .../External/Elements/HtmlElements.swift | 86 +- .../External/Elements/InputElements.swift | 88 +- .../External/Elements/ListElements.swift | 22 +- .../External/Elements/MapElements.swift | 22 +- .../External/Elements/MediaElements.swift | 44 +- .../External/Elements/ObjectElements.swift | 22 +- .../External/Elements/RubyElements.swift | 44 +- .../External/Elements/TableElements.swift | 198 +- Sources/HTMLKit/External/Events.swift | 330 +++ Tests/HTMLKitTests/AttributesTests.swift | 290 ++- 17 files changed, 3014 insertions(+), 2233 deletions(-) create mode 100644 Sources/HTMLKit/External/Events.swift diff --git a/Sources/HTMLKit/External/Attributes/EventAttributes.swift b/Sources/HTMLKit/External/Attributes/EventAttributes.swift index 5c3fe640..cf98c2a9 100644 --- a/Sources/HTMLKit/External/Attributes/EventAttributes.swift +++ b/Sources/HTMLKit/External/Attributes/EventAttributes.swift @@ -2,12 +2,6 @@ Abstract: The file contains the protocols for the event html-attributes. - Authors: - - Mats Moll (https://github.com/matsmoll) - - Contributors: - - Mattes Mohr (https://github.com/mattesmohr) - Note: If you about to add something to the file, stick to the official documentation to keep the code consistent. */ @@ -15,2104 +9,147 @@ import OrderedCollections /// The alias combines the global attributes of the event attributes. -public typealias GlobalEventAttributes = ContextMenuEventAttribute & WheelEventAttribute & DragEventAttribute & DragEndEventAttribute & DragEnterEventAttribute & DragLeaveEventAttribute & DragOverEventAttribute & DragStartEventAttribute & DropEventAttribute - -/// The protocol provides the element with the onafterprint handler. -public protocol AfterPrintEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onafterprint'. - /// - /// ```html - /// - /// ``` - func onAfterPrint(_ value: String) -> Self -} - -extension AfterPrintEventAttribute { - - internal var key: String { "onafterprint" } -} - -extension AfterPrintEventAttribute where Self: ContentNode { - - internal func mutate(onafterprint value: String) -> Self { - return self.mutate(key: key, value: value) - } -} - -extension AfterPrintEventAttribute where Self: EmptyNode { - - internal func mutate(onafterprint value: String) -> Self { - return self.mutate(key: key, value: value) - } -} - -/// The protocol provides the element with the onbeforeprint handler. -public protocol BeforePrintEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onbeforeprint'. - /// - /// ```html - /// - /// ``` - func onBeforePrint(_ value: String) -> Self -} - -extension BeforePrintEventAttribute { - - internal var key: String { "onbeforeprint" } -} - -extension BeforePrintEventAttribute where Self: ContentNode { - - internal func mutate(onbeforeprint value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension BeforePrintEventAttribute where Self: EmptyNode { - - internal func mutate(onbeforeprint value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onbeforeunload handler. -public protocol BeforeUnloadEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onbeforeunload'. - /// - /// ```html - /// - /// ``` - func onBeforeUnload(_ value: String) -> Self -} - -extension BeforeUnloadEventAttribute { - - internal var key: String { "onbeforeunload" } -} - -extension BeforeUnloadEventAttribute where Self: ContentNode { - - internal func mutate(onbeforeunload value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension BeforeUnloadEventAttribute where Self: EmptyNode { - - internal func mutate(onbeforeunload value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onerror handler. -public protocol ErrorEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onerror'. - /// - /// ```html - /// - /// ``` - func onError(_ value: String) -> Self -} - -extension ErrorEventAttribute { - - internal var key: String { "onerror" } -} - -extension ErrorEventAttribute where Self: ContentNode { - - internal func mutate(onerror value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ErrorEventAttribute where Self: EmptyNode { - - internal func mutate(onerror value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onhashchange handler. -public protocol HashChangeEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onhashchange'. - /// - /// ```html - /// - /// ``` - func onHashChange(_ value: String) -> Self -} - -extension HashChangeEventAttribute { - - internal var key: String { "onhashchange" } -} - -extension HashChangeEventAttribute where Self: ContentNode { - - internal func mutate(onhashchange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension HashChangeEventAttribute where Self: EmptyNode { - - internal func mutate(onhashchange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onload handler. -public protocol LoadEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onload'. - /// - /// ```html - /// - /// ``` - func onLoad(_ value: String) -> Self -} - -extension LoadEventAttribute { - - internal var key: String { "onload" } -} - -extension LoadEventAttribute where Self: ContentNode { - - internal func mutate(onload value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension LoadEventAttribute where Self: EmptyNode { - - internal func mutate(onload value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onmessage handler. -public protocol MessageEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onmessage'. - /// - /// ```html - /// - /// ``` - func onMessage(_ value: String) -> Self -} - -extension MessageEventAttribute { - - internal var key: String { "onmessage" } -} - -extension MessageEventAttribute where Self: ContentNode { - - internal func mutate(onmessage value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension MessageEventAttribute where Self: EmptyNode { - - internal func mutate(onmessage value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onoffline handler. -public protocol OfflineEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onoffline'. - /// - /// ```html - /// - /// ``` - func onOffline(_ value: String) -> Self -} - -extension OfflineEventAttribute { - - internal var key: String { "onoffline" } -} - -extension OfflineEventAttribute where Self: ContentNode { - - internal func mutate(onoffline value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension OfflineEventAttribute where Self: EmptyNode { - - internal func mutate(onoffline value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ononline handler. -public protocol OnlineEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ononline'. - /// - /// ```html - /// - /// ``` - func onOnline(_ value: String) -> Self -} +public typealias GlobalEventAttributes = ClipboardEventAttribute & DragEventAttribute & WheelEventAttribute & KeyboardEventAttribute & MouseEventAttribute -extension OnlineEventAttribute { +/// The protocol provides the element with event handler. +public protocol WindowEventAttribute: AnyAttribute { - internal var key: String { "ononline" } -} - -extension OnlineEventAttribute where Self: ContentNode { - - internal func mutate(ononline value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension OnlineEventAttribute where Self: EmptyNode { - - internal func mutate(ononline value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onpagehide handler. -public protocol PageHideEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onpagehide'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onPageHide(_ value: String) -> Self -} - -extension PageHideEventAttribute { - - internal var key: String { "onpagehide" } -} - -extension PageHideEventAttribute where Self: ContentNode { - - internal func mutate(onpagehide value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension PageHideEventAttribute where Self: EmptyNode { - - internal func mutate(onpagehide value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Window, _ value: String) -> Self } -/// The protocol provides the element with the onpageshow handler. -public protocol PageShowEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol FocusEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'onpageshow'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onPageShow(_ value: String) -> Self -} - -extension PageShowEventAttribute { - - internal var key: String { "onpageshow" } -} - -extension PageShowEventAttribute where Self: ContentNode { - - internal func mutate(onpageshow value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Focus, _ value: String) -> Self } -extension PageShowEventAttribute where Self: EmptyNode { - - internal func mutate(onpageshow value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} +/// The protocol provides the element with event handler. +public protocol PointerEventAttribute: AnyAttribute { -/// The protocol provides the element with the onpopstate handler. -public protocol PopstateEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onpopstate'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onPopstate(_ value: String) -> Self -} - -extension PopstateEventAttribute { - - internal var key: String { "onpopstate" } -} - -extension PopstateEventAttribute where Self: ContentNode { - - internal func mutate(onpopstate value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension PopstateEventAttribute where Self: EmptyNode { - - internal func mutate(onpopstate value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Pointer, _ value: String) -> Self } -/// The protocol provides the element with the onresize handler. -public protocol ResizeEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol MouseEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'onresize'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onResize(_ value: String) -> Self -} - -extension ResizeEventAttribute { - - internal var key: String { "onresize" } + func on(event: Events.Mouse, _ value: String) -> Self } -extension ResizeEventAttribute where Self: ContentNode { - - internal func mutate(onresize value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ResizeEventAttribute where Self: EmptyNode { - - internal func mutate(onresize value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onstorage handler. -public protocol StorageEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol WheelEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'onstorage'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onStorage(_ value: String) -> Self -} - -extension StorageEventAttribute { - - internal var key: String { "onstorage" } -} - -extension StorageEventAttribute where Self: ContentNode { - - internal func mutate(onstorage value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension StorageEventAttribute where Self: EmptyNode { - - internal func mutate(onstorage value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Wheel, _ value: String) -> Self } -/// The protocol provides the element with the onunload handler. -public protocol UnloadEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol InputEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'onunload'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onUnload(_ value: String) -> Self -} - -extension UnloadEventAttribute { - - internal var key: String { "onunload" } -} - -extension UnloadEventAttribute where Self: ContentNode { - - internal func mutate(onunload value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension UnloadEventAttribute where Self: EmptyNode { - - internal func mutate(onunload value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Input, _ value: String) -> Self } -/// The protocol provides the element with the onblur handler. -public protocol BlurEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol KeyboardEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'onblur'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onBlur(_ value: String) -> Self -} - -extension BlurEventAttribute { - - internal var key: String { "onblur" } -} - -extension BlurEventAttribute where Self: ContentNode { - - internal func mutate(onblur value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Keyboard, _ value: String) -> Self } -extension BlurEventAttribute where Self: EmptyNode { - - internal func mutate(onblur value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onchange handler. -public protocol ChangeEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol DragEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'onchange'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onChange(_ value: String) -> Self -} - -extension ChangeEventAttribute { - - internal var key: String { "onchange" } -} - -extension ChangeEventAttribute where Self: ContentNode { - - internal func mutate(onchange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ChangeEventAttribute where Self: EmptyNode { - - internal func mutate(onchange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Drag, _ value: String) -> Self } -/// The protocol provides the element with the oncontextmenu handler. -public protocol ContextMenuEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol ClipboardEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'oncontextmenu'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onContextMenu(_ value: String) -> Self -} - -extension ContextMenuEventAttribute { - - internal var key: String { "oncontextmenu" } + func on(event: Events.Clipboard, _ value: String) -> Self } -extension ContextMenuEventAttribute where Self: ContentNode { +/// The protocol provides the element with event handler. +public protocol SelectionEventAttribute: AnyAttribute { - internal func mutate(oncontextmenu value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ContextMenuEventAttribute where Self: EmptyNode { - - internal func mutate(oncontextmenu value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onfocus handler. -public protocol FocusEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onfocus'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onFocus(_ value: String) -> Self -} - -extension FocusEventAttribute { - - internal var key: String { "onfocus" } -} - -extension FocusEventAttribute where Self: ContentNode { - - internal func mutate(onfocus value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension FocusEventAttribute where Self: EmptyNode { - - internal func mutate(onfocus value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Selection, _ value: String) -> Self } -/// The protocol provides the element with the oninput handler. -public protocol InputEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler.r. +public protocol MediaEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'oninput'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onInput(_ value: String) -> Self -} - -extension InputEventAttribute { - - internal var key: String { "oninput" } -} - -extension InputEventAttribute where Self: ContentNode { - - internal func mutate(oninput value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension InputEventAttribute where Self: EmptyNode { - - internal func mutate(oninput value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Media, _ value: String) -> Self } -/// The protocol provides the element with the oninvalid handler. -public protocol InvalidEventAttribute: AnyAttribute { +/// The protocol provides the element with event handler. +public protocol FormEventAttribute: AnyAttribute { - /// The function represents the html-attribute 'oninvalid'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onInvalid(_ value: String) -> Self -} - -extension InvalidEventAttribute { - - internal var key: String { "oninvalid" } -} - -extension InvalidEventAttribute where Self: ContentNode { - - internal func mutate(oninvalid value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Form, _ value: String) -> Self } -extension InvalidEventAttribute where Self: EmptyNode { +/// The protocol provides the element with event handler. +public protocol DetailEventAttribute: AnyAttribute { - internal func mutate(oninvalid value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onreset handler. -public protocol ResetEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onreset'. + /// The function represents the html-attribute 'on'. /// /// ```html - /// + /// /// ``` - func onReset(_ value: String) -> Self -} - -extension ResetEventAttribute { - - internal var key: String { "onreset" } -} - -extension ResetEventAttribute where Self: ContentNode { - - internal func mutate(onreset value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ResetEventAttribute where Self: EmptyNode { - - internal func mutate(onreset value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onsearch handler. -public protocol SearchEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onsearch'. - /// - /// ```html - /// - /// ``` - func onSearch(_ value: String) -> Self -} - -extension SearchEventAttribute { - - internal var key: String { "onsearch" } -} - -extension SearchEventAttribute where Self: ContentNode { - - internal func mutate(onsearch value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension SearchEventAttribute where Self: EmptyNode { - - internal func mutate(onsearch value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onselect handler. -public protocol SelectEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onselect'. - /// - /// ```html - /// - /// ``` - func onSelect(_ value: String) -> Self -} - -extension SelectEventAttribute { - - internal var key: String { "onselect" } -} - -extension SelectEventAttribute where Self: ContentNode { - - internal func mutate(onselect value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension SelectEventAttribute where Self: EmptyNode { - - internal func mutate(onselect value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onsubmit handler. -public protocol SubmitEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onsubmit'. - /// - /// ```html - /// - /// ``` - func onSubmit(_ value: String) -> Self -} - -extension SubmitEventAttribute { - - internal var key: String { "onsubmit" } -} - -extension SubmitEventAttribute where Self: ContentNode { - - internal func mutate(onsubmit value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension SubmitEventAttribute where Self: EmptyNode { - - internal func mutate(onsubmit value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onkeydown handler. -public protocol KeyDownEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onkeydown'. - /// - /// ```html - /// - /// ``` - func onKeyDown(_ value: String) -> Self -} - -extension KeyDownEventAttribute { - - internal var key: String { "onkeydown" } -} - -extension KeyDownEventAttribute where Self: ContentNode { - - internal func mutate(onkeydown value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension KeyDownEventAttribute where Self: EmptyNode { - - internal func mutate(onkeydown value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onkeypress handler -public protocol KeyPressEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onkeypress'. - /// - /// ```html - /// - /// ``` - func onKeyPress(_ value: String) -> Self -} - -extension KeyPressEventAttribute { - - internal var key: String { "onkeypress" } -} - -extension KeyPressEventAttribute where Self: ContentNode { - - internal func mutate(onkeypress value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension KeyPressEventAttribute where Self: EmptyNode { - - internal func mutate(onkeypress value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onkeyup handler. -public protocol KeyUpEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onkeyup'. - /// - /// ```html - /// - /// ``` - func onKeyUp(_ value: String) -> Self -} - -extension KeyUpEventAttribute { - - internal var key: String { "onkeyup" } -} - -extension KeyUpEventAttribute where Self: ContentNode { - - internal func mutate(onkeyup value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension KeyUpEventAttribute where Self: EmptyNode { - - internal func mutate(onkeyup value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onclick handler. -public protocol ClickEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onclick'. - /// - /// ```html - /// - /// ``` - func onClick(_ value: String) -> Self -} - -extension ClickEventAttribute { - - internal var key: String { "onclick" } -} - -extension ClickEventAttribute where Self: ContentNode { - - internal func mutate(onclick value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ClickEventAttribute where Self: EmptyNode { - - internal func mutate(onclick value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondbclick handler. -public protocol DoubleClickEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondbclick'. - /// - /// ```html - /// - /// ``` - func onDoubleClick(_ value: String) -> Self -} - -extension DoubleClickEventAttribute { - - internal var key: String { "ondbclick" } -} - -extension DoubleClickEventAttribute where Self: ContentNode { - - internal func mutate(ondbclick value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DoubleClickEventAttribute where Self: EmptyNode { - - internal func mutate(ondbclick value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onmousedown handler. -public protocol MouseDownEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onmousedown'. - /// - /// ```html - /// - /// ``` - func onMouseDown(_ value: String) -> Self -} - -extension MouseDownEventAttribute { - - internal var key: String { "onmousedown" } -} - -extension MouseDownEventAttribute where Self: ContentNode { - - internal func mutate(onmousedown value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension MouseDownEventAttribute where Self: EmptyNode { - - internal func mutate(onmousedown value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onmousemove handler. -public protocol MouseMoveEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onmousemove'. - /// - /// ```html - /// - /// ``` - func onMouseMove(_ value: String) -> Self -} - -extension MouseMoveEventAttribute { - - internal var key: String { "onmousemove" } -} - -extension MouseMoveEventAttribute where Self: ContentNode { - - internal func mutate(onmousemove value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension MouseMoveEventAttribute where Self: EmptyNode { - - internal func mutate(onmousemove value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onmouseout handler. -public protocol MouseOutEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onmouseout'. - /// - /// ```html - /// - /// ``` - func onMouseOut(_ value: String) -> Self -} - -extension MouseOutEventAttribute { - - internal var key: String { "onmouseout" } -} - -extension MouseOutEventAttribute where Self: ContentNode { - - internal func mutate(onmouseout value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension MouseOutEventAttribute where Self: EmptyNode { - - internal func mutate(onmouseout value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onmouseover handler. -public protocol MouseOverEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onmouseover'. - /// - /// ```html - /// - /// ``` - func onMouseOver(_ value: String) -> Self -} - -extension MouseOverEventAttribute { - - internal var key: String { "onmouseover" } -} - -extension MouseOverEventAttribute where Self: ContentNode { - - internal func mutate(onmouseover value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension MouseOverEventAttribute where Self: EmptyNode { - - internal func mutate(onmouseover value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onmouseup handler. -public protocol MouseUpEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onmouseup'. - /// - /// ```html - /// - /// ``` - func onMouseUp(_ value: String) -> Self -} - -extension MouseUpEventAttribute { - - internal var key: String { "onmouseup" } -} - -extension MouseUpEventAttribute where Self: ContentNode { - - internal func mutate(onmouseup value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension MouseUpEventAttribute where Self: EmptyNode { - - internal func mutate(onmouseup value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onwheel handler. -public protocol WheelEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onwheel'. - /// - /// ```html - /// onwheel="" /> - /// ``` - func onWheel(_ value: String) -> Self -} - -extension WheelEventAttribute { - - internal var key: String { "onwheel" } -} - -extension WheelEventAttribute where Self: ContentNode { - - internal func mutate(onwheel value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension WheelEventAttribute where Self: EmptyNode { - - internal func mutate(onwheel value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondrag handler. -public protocol DragEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondrag'. - /// - /// ```html - /// - /// ``` - func onDrag(_ value: String) -> Self -} - -extension DragEventAttribute { - - internal var key: String { "ondrag" } -} - -extension DragEventAttribute where Self: ContentNode { - - internal func mutate(ondrag value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DragEventAttribute where Self: EmptyNode { - - internal func mutate(ondrag value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondragenter handler. -public protocol DragEnterEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondragenter'. - /// - /// ```html - /// - /// ``` - func onDragEnter(_ value: String) -> Self -} - -extension DragEnterEventAttribute { - - internal var key: String { "ondragenter" } -} - -extension DragEnterEventAttribute where Self: ContentNode { - - internal func mutate(ondragenter value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DragEnterEventAttribute where Self: EmptyNode { - - internal func mutate(ondragenter value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondragend handler. -public protocol DragEndEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondragend'. - /// - /// ```html - /// - /// ``` - func onDragEnd(_ value: String) -> Self -} - -extension DragEndEventAttribute { - - internal var key: String { "ondragend" } -} - -extension DragEndEventAttribute where Self: ContentNode { - - internal func mutate(ondragend value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DragEndEventAttribute where Self: EmptyNode { - - internal func mutate(ondragend value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondragleave handler. -public protocol DragLeaveEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondragleave'. - /// - /// ```html - /// - /// ``` - func onDragLeave(_ value: String) -> Self -} - -extension DragLeaveEventAttribute { - - internal var key: String { "ondragleave" } -} - -extension DragLeaveEventAttribute where Self: ContentNode { - - internal func mutate(ondragleave value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DragLeaveEventAttribute where Self: EmptyNode { - - internal func mutate(ondragleave value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondragover handler. -public protocol DragOverEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondragover'. - /// - /// ```html - /// - /// ``` - func onDragOver(_ value: String) -> Self -} - -extension DragOverEventAttribute { - - internal var key: String { "ondragover" } -} - -extension DragOverEventAttribute where Self: ContentNode { - - internal func mutate(ondragover value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DragOverEventAttribute where Self: EmptyNode { - - internal func mutate(ondragover value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondragstart handler. -public protocol DragStartEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondragstart'. - /// - /// ```html - /// - /// ``` - func onDragStart(_ value: String) -> Self -} - -extension DragStartEventAttribute { - - internal var key: String { "ondragstart" } -} - -extension DragStartEventAttribute where Self: ContentNode { - - internal func mutate(ondragstart value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DragStartEventAttribute where Self: EmptyNode { - - internal func mutate(ondragstart value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondrop handler. -public protocol DropEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondrop'. - /// - /// ```html - /// - /// ``` - func onDrop(_ value: String) -> Self -} - -extension DropEventAttribute { - - internal var key: String { "ondrop" } -} - -extension DropEventAttribute where Self: ContentNode { - - internal func mutate(ondrop value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DropEventAttribute where Self: EmptyNode { - - internal func mutate(ondrop value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onscroll handler. -public protocol ScrollEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onscroll'. - /// - /// ```html - /// - /// ``` - func onScroll(_ value: String) -> Self -} - -extension ScrollEventAttribute { - - internal var key: String { "onscroll" } -} - -extension ScrollEventAttribute where Self: ContentNode { - - internal func mutate(onscroll value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ScrollEventAttribute where Self: EmptyNode { - - internal func mutate(onscroll value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the oncopy handler. -public protocol CopyEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'oncopy'. - /// - /// ```html - /// - /// ``` - func onCopy(_ value: String) -> Self -} - -extension CopyEventAttribute { - - internal var key: String { "oncopy" } -} - -extension CopyEventAttribute where Self: ContentNode { - - internal func mutate(oncopy value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension CopyEventAttribute where Self: EmptyNode { - - internal func mutate(oncopy value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the oncut handler. -public protocol CutEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'oncut'. - /// - /// ```html - /// - /// ``` - func onCut(_ value: String) -> Self -} - -extension CutEventAttribute { - - internal var key: String { "oncut" } -} - -extension CutEventAttribute where Self: ContentNode { - - internal func mutate(oncut value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension CutEventAttribute where Self: EmptyNode { - - internal func mutate(oncut value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onpaste handler. -public protocol PasteEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onpaste'. - /// - /// ```html - /// - /// ``` - func onPaste(_ value: String) -> Self -} - -extension PasteEventAttribute { - - internal var key: String { "onpaste" } -} - -extension PasteEventAttribute where Self: ContentNode { - - internal func mutate(onpaste value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension PasteEventAttribute where Self: EmptyNode { - - internal func mutate(onpaste value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onabort handler. -public protocol AbortEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onabort'. - /// - /// ```html - /// - /// ``` - func onAbort(_ value: String) -> Self -} - -extension AbortEventAttribute { - - internal var key: String { "onabort" } -} - -extension AbortEventAttribute where Self: ContentNode { - - internal func mutate(onabort value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension AbortEventAttribute where Self: EmptyNode { - - internal func mutate(onabort value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the oncanplay handler. -public protocol CanPlayEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'oncanplay'. - /// - /// ```html - /// - /// ``` - func onCanPlay(_ value: String) -> Self -} - -extension CanPlayEventAttribute { - - internal var key: String { "oncanplay" } -} - -extension CanPlayEventAttribute where Self: ContentNode { - - internal func mutate(oncanplay value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension CanPlayEventAttribute where Self: EmptyNode { - - internal func mutate(oncanplay value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the oncanplaythrough handler. -public protocol CanPlayThroughEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'oncanplaythrough'. - /// - /// ```html - /// - /// ``` - func onCanPlayThrough(_ value: String) -> Self -} - -extension CanPlayThroughEventAttribute { - - internal var key: String { "oncanplaythrough" } -} - -extension CanPlayThroughEventAttribute where Self: ContentNode { - - internal func mutate(oncanplaythrough value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension CanPlayThroughEventAttribute where Self: EmptyNode { - - internal func mutate(oncanplaythrough value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the oncuechange handler. -public protocol CueChangeEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'oncuechange'. - /// - /// ```html - /// - /// ``` - func onCueChange(_ value: String) -> Self -} - -extension CueChangeEventAttribute { - - internal var key: String { "oncuechange" } -} - -extension CueChangeEventAttribute where Self: ContentNode { - - internal func mutate(oncuechange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension CueChangeEventAttribute where Self: EmptyNode { - - internal func mutate(oncuechange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ondurationchange handler. -public protocol DurationChangeEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ondurationchange'. - /// - /// ```html - /// - /// ``` - func onDurationChange(_ value: String) -> Self -} - -extension DurationChangeEventAttribute { - - internal var key: String { "ondurationchange" } -} - -extension DurationChangeEventAttribute where Self: ContentNode { - - internal func mutate(ondurationchange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension DurationChangeEventAttribute where Self: EmptyNode { - - internal func mutate(ondurationchange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onemptied handler. -public protocol EmptiedEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onemptied'. - /// - /// ```html - /// - /// ``` - func onEmptied(_ value: String) -> Self -} - -extension EmptiedEventAttribute { - - internal var key: String { "onemptied" } -} - -extension EmptiedEventAttribute where Self: ContentNode { - - internal func mutate(onemptied value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension EmptiedEventAttribute where Self: EmptyNode { - - internal func mutate(onemptied value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onended handler. -public protocol EndedEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onended'. - /// - /// ```html - /// - /// ``` - func onEnded(_ value: String) -> Self -} - -extension EndedEventAttribute { - - internal var key: String { "onended" } -} - -extension EndedEventAttribute where Self: ContentNode { - - internal func mutate(onended value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension EndedEventAttribute where Self: EmptyNode { - - internal func mutate(onended value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onloadeddata handler. -public protocol LoadedDataEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onloadeddata'. - /// - /// ```html - /// - /// ``` - func onLoadedData(_ value: String) -> Self -} - -extension LoadedDataEventAttribute { - - internal var key: String { "onloadeddata" } -} - -extension LoadedDataEventAttribute where Self: ContentNode { - - internal func mutate(onloadeddata value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension LoadedDataEventAttribute where Self: EmptyNode { - - internal func mutate(onloadeddata value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onloadedmetadata handler. -public protocol LoadedMetaDataEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onloadedmetadata'. - /// - /// ```html - /// - /// ``` - func onLoadedMetaData(_ value: String) -> Self -} - -extension LoadedMetaDataEventAttribute { - - internal var key: String { "onloadedmetadata" } -} - -extension LoadedMetaDataEventAttribute where Self: ContentNode { - - internal func mutate(onloadedmetadata value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension LoadedMetaDataEventAttribute where Self: EmptyNode { - - internal func mutate(onloadedmetadata value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onloadstart handler. -public protocol LoadStartEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onloadstart'. - /// - /// ```html - /// - /// ``` - func onLoadStart(_ value: String) -> Self -} - -extension LoadStartEventAttribute { - - internal var key: String { "onloadstart" } -} - -extension LoadStartEventAttribute where Self: ContentNode { - - internal func mutate(onloadstart value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension LoadStartEventAttribute where Self: EmptyNode { - - internal func mutate(onloadstart value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onpause handler. -public protocol PauseEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onpause'. - /// - /// ```html - /// - /// ``` - func onPause(_ value: String) -> Self -} - -extension PauseEventAttribute { - - internal var key: String { "onpause" } -} - -extension PauseEventAttribute where Self: ContentNode { - - internal func mutate(onpause value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension PauseEventAttribute where Self: EmptyNode { - - internal func mutate(onpause value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onplay handler. -public protocol PlayEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onplay'. - /// - /// ```html - /// - /// ``` - func onPlay(_ value: String) -> Self -} - -extension PlayEventAttribute { - - internal var key: String { "onplay" } -} - -extension PlayEventAttribute where Self: ContentNode { - - internal func mutate(onplay value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension PlayEventAttribute where Self: EmptyNode { - - internal func mutate(onplay value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onplaying handler. -public protocol PlayingEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onplaying'. - /// - /// ```html - /// - /// ``` - func OnPlaying(_ value: String) -> Self -} - -extension PlayingEventAttribute { - - internal var key: String { "onplaying" } -} - -extension PlayingEventAttribute where Self: ContentNode { - - internal func mutate(onplaying value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension PlayingEventAttribute where Self: EmptyNode { - - internal func mutate(onplaying value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onprogress handler. -public protocol ProgressEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onprogress'. - /// - /// ```html - /// - /// ``` - func onProgress(_ value: String) -> Self -} - -extension ProgressEventAttribute { - - internal var key: String { "onprogress" } -} - -extension ProgressEventAttribute where Self: ContentNode { - - internal func mutate(onprogress value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ProgressEventAttribute where Self: EmptyNode { - - internal func mutate(onprogress value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onratechange handler. -public protocol RateChangeEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onratechange'. - /// - /// ```html - /// - /// ``` - func onRateChange(_ value: String) -> Self -} - -extension RateChangeEventAttribute { - - internal var key: String { "onratechange" } -} - -extension RateChangeEventAttribute where Self: ContentNode { - - internal func mutate(onratechange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension RateChangeEventAttribute where Self: EmptyNode { - - internal func mutate(onratechange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onseeked handler. -public protocol SeekedEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onseeked'. - /// - /// ```html - /// - /// ``` - func onSeeked(_ value: String) -> Self -} - -extension SeekedEventAttribute { - - internal var key: String { "onseeked" } -} - -extension SeekedEventAttribute where Self: ContentNode { - - internal func mutate(onseeked value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension SeekedEventAttribute where Self: EmptyNode { - - internal func mutate(onseeked value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onseeking handler. -public protocol SeekingEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onseeking'. - /// - /// ```html - /// - /// ``` - func onSeeking(_ value: String) -> Self -} - -extension SeekingEventAttribute { - - internal var key: String { "onseeking" } -} - -extension SeekingEventAttribute where Self: ContentNode { - - internal func mutate(onseeking value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension SeekingEventAttribute where Self: EmptyNode { - - internal func mutate(onseeking value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onstalled handler. -public protocol StalledEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onstalled'. - /// - /// ```html - /// - /// ``` - func onStalled(_ value: String) -> Self -} - -extension StalledEventAttribute { - - internal var key: String { "onstalled" } -} - -extension StalledEventAttribute where Self: ContentNode { - - internal func mutate(onstalled value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension StalledEventAttribute where Self: EmptyNode { - - internal func mutate(onstalled value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onsuspend handler. -public protocol SuspendEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onsuspend'. - /// - /// ```html - /// - /// ``` - func onSuspend(_ value: String) -> Self -} - -extension SuspendEventAttribute { - - internal var key: String { "onsuspend" } -} - -extension SuspendEventAttribute where Self: ContentNode { - - internal func mutate(onsuspend value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension SuspendEventAttribute where Self: EmptyNode { - - internal func mutate(onsuspend value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ontimeupdate handler. -public protocol TimeUpdateEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ontimeupdate'. - /// - /// ```html - /// - /// ``` - func onTimeUpdate(_ value: String) -> Self -} - -extension TimeUpdateEventAttribute { - - internal var key: String { "ontimeupdate" } -} - -extension TimeUpdateEventAttribute where Self: ContentNode { - - internal func mutate(ontimeupdate value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension TimeUpdateEventAttribute where Self: EmptyNode { - - internal func mutate(ontimeupdate value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onvolumechange handler. -public protocol VolumeChangeEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onvolumechange'. - /// - /// ```html - /// - /// ``` - func onVolumeChange(_ value: String) -> Self -} - -extension VolumeChangeEventAttribute { - - internal var key: String { "onvolumechange" } -} - -extension VolumeChangeEventAttribute where Self: ContentNode { - - internal func mutate(onvolumechange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension VolumeChangeEventAttribute where Self: EmptyNode { - - internal func mutate(onvolumechange value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the onwaiting handler. -public protocol WaitingEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'onwaiting'. - /// - /// ```html - /// - /// ``` - func onWaiting(_ value: String) -> Self -} - -extension WaitingEventAttribute { - - internal var key: String { "onwaiting" } -} - -extension WaitingEventAttribute where Self: ContentNode { - - internal func mutate(onwaiting value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension WaitingEventAttribute where Self: EmptyNode { - - internal func mutate(onwaiting value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -/// The protocol provides the element with the ontoggle handler. -public protocol ToggleEventAttribute: AnyAttribute { - - /// The function represents the html-attribute 'ontoggle'. - /// - /// ```html - /// - /// ``` - func onToggle(_ value: String) -> Self -} - -extension ToggleEventAttribute { - - internal var key: String { "ontoggle" } -} - -extension ToggleEventAttribute where Self: ContentNode { - - internal func mutate(ontoggle value: String) -> Self { - return self.mutate(key: self.key, value: value) - } -} - -extension ToggleEventAttribute where Self: EmptyNode { - - internal func mutate(ontoggle value: String) -> Self { - return self.mutate(key: self.key, value: value) - } + func on(event: Events.Detail, _ value: String) -> Self } diff --git a/Sources/HTMLKit/External/Elements/BasicElements.swift b/Sources/HTMLKit/External/Elements/BasicElements.swift index 3affd521..6bebed91 100644 --- a/Sources/HTMLKit/External/Elements/BasicElements.swift +++ b/Sources/HTMLKit/External/Elements/BasicElements.swift @@ -87,7 +87,7 @@ public struct Html: ContentNode, BasicElement { } } -extension Html: GlobalAttributes { +extension Html: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Html { return mutate(accesskey: value) @@ -206,6 +206,26 @@ extension Html: GlobalAttributes { public func custom(key: String, value: Any) -> Html { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Html { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Html { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Html { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Html { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Html { + return mutate(key: event.rawValue, value: value) + } } extension Html: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/BodyElements.swift b/Sources/HTMLKit/External/Elements/BodyElements.swift index ef2c027b..25b53c31 100644 --- a/Sources/HTMLKit/External/Elements/BodyElements.swift +++ b/Sources/HTMLKit/External/Elements/BodyElements.swift @@ -370,7 +370,7 @@ public struct Article: ContentNode, HtmlElement, BodyElement, FormElement, Figur } } -extension Article: GlobalAttributes { +extension Article: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Article { return mutate(accesskey: value) @@ -489,6 +489,26 @@ extension Article: GlobalAttributes { public func custom(key: String, value: Any) -> Article { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Article { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Article { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Article { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Article { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Article { + return mutate(key: event.rawValue, value: value) + } } extension Article: AnyContent { @@ -561,7 +581,7 @@ public struct Section: ContentNode, HtmlElement, BodyElement, FigureElement, For } } -extension Section: GlobalAttributes { +extension Section: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Section { return mutate(accesskey: value) @@ -680,6 +700,26 @@ extension Section: GlobalAttributes { public func custom(key: String, value: Any) -> Section { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Section { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Section { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Section { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Section { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Section { + return mutate(key: event.rawValue, value: value) + } } extension Section: AnyContent { @@ -752,7 +792,7 @@ public struct Navigation: ContentNode, HtmlElement, BodyElement, FormElement, Fi } } -extension Navigation: GlobalAttributes { +extension Navigation: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Navigation { return mutate(accesskey: value) @@ -871,6 +911,26 @@ extension Navigation: GlobalAttributes { public func custom(key: String, value: Any) -> Navigation { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Navigation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Navigation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Navigation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Navigation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Navigation { + return mutate(key: event.rawValue, value: value) + } } extension Navigation: AnyContent { @@ -943,7 +1003,7 @@ public struct Aside: ContentNode, HtmlElement, BodyElement, FormElement, FigureE } } -extension Aside: GlobalAttributes { +extension Aside: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Aside { return mutate(accesskey: value) @@ -1062,6 +1122,26 @@ extension Aside: GlobalAttributes { public func custom(key: String, value: Any) -> Aside { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Aside { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Aside { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Aside { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Aside { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Aside { + return mutate(key: event.rawValue, value: value) + } } extension Aside: AnyContent { @@ -1134,7 +1214,7 @@ public struct Heading1: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Heading1: GlobalAttributes { +extension Heading1: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Heading1 { return mutate(accesskey: value) @@ -1253,6 +1333,26 @@ extension Heading1: GlobalAttributes { public func custom(key: String, value: Any) -> Heading1 { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Heading1 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Heading1 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Heading1 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Heading1 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Heading1 { + return mutate(key: event.rawValue, value: value) + } } extension Heading1: AnyContent { @@ -1336,7 +1436,7 @@ public struct Heading2: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Heading2: GlobalAttributes { +extension Heading2: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Heading2 { return mutate(accesskey: value) @@ -1455,6 +1555,26 @@ extension Heading2: GlobalAttributes { public func custom(key: String, value: Any) -> Heading2 { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Heading2 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Heading2 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Heading2 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Heading2 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Heading2 { + return mutate(key: event.rawValue, value: value) + } } extension Heading2: AnyContent { @@ -1538,7 +1658,7 @@ public struct Heading3: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Heading3: GlobalAttributes { +extension Heading3: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Heading3 { return mutate(accesskey: value) @@ -1657,6 +1777,26 @@ extension Heading3: GlobalAttributes { public func custom(key: String, value: Any) -> Heading3 { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Heading3 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Heading3 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Heading3 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Heading3 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Heading3 { + return mutate(key: event.rawValue, value: value) + } } extension Heading3: AnyContent { @@ -1740,7 +1880,7 @@ public struct Heading4: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Heading4: GlobalAttributes { +extension Heading4: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Heading4 { return mutate(accesskey: value) @@ -1859,6 +1999,26 @@ extension Heading4: GlobalAttributes { public func custom(key: String, value: Any) -> Heading4 { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Heading4 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Heading4 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Heading4 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Heading4 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Heading4 { + return mutate(key: event.rawValue, value: value) + } } extension Heading4: AnyContent { @@ -1942,7 +2102,7 @@ public struct Heading5: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Heading5: GlobalAttributes { +extension Heading5: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Heading5 { return mutate(accesskey: value) @@ -2061,6 +2221,26 @@ extension Heading5: GlobalAttributes { public func custom(key: String, value: Any) -> Heading5 { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Heading5 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Heading5 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Heading5 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Heading5 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Heading5 { + return mutate(key: event.rawValue, value: value) + } } extension Heading5: AnyContent { @@ -2144,7 +2324,7 @@ public struct Heading6: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Heading6: GlobalAttributes { +extension Heading6: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Heading6 { return mutate(accesskey: value) @@ -2263,6 +2443,26 @@ extension Heading6: GlobalAttributes { public func custom(key: String, value: Any) -> Heading6 { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Heading6 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Heading6 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Heading6 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Heading6 { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Heading6 { + return mutate(key: event.rawValue, value: value) + } } extension Heading6: AnyContent { @@ -2346,7 +2546,7 @@ public struct HeadingGroup: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension HeadingGroup: GlobalAttributes { +extension HeadingGroup: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> HeadingGroup { return mutate(accesskey: value) @@ -2465,6 +2665,26 @@ extension HeadingGroup: GlobalAttributes { public func custom(key: String, value: Any) -> HeadingGroup { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> HeadingGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> HeadingGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> HeadingGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> HeadingGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> HeadingGroup { + return mutate(key: event.rawValue, value: value) + } } extension HeadingGroup: AnyContent { @@ -2537,7 +2757,7 @@ public struct Header: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Header: GlobalAttributes { +extension Header: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Header { return mutate(accesskey: value) @@ -2656,6 +2876,26 @@ extension Header: GlobalAttributes { public func custom(key: String, value: Any) -> Header { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Header { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Header { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Header { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Header { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Header { + return mutate(key: event.rawValue, value: value) + } } extension Header: AnyContent { @@ -2728,7 +2968,7 @@ public struct Footer: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Footer: GlobalAttributes { +extension Footer: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Footer { return mutate(accesskey: value) @@ -2847,6 +3087,26 @@ extension Footer: GlobalAttributes { public func custom(key: String, value: Any) -> Footer { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Footer { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Footer { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Footer { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Footer { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Footer { + return mutate(key: event.rawValue, value: value) + } } extension Footer: AnyContent { @@ -2919,7 +3179,7 @@ public struct Address: ContentNode, HtmlElement, BodyElement, FormElement, Figur } } -extension Address: GlobalAttributes { +extension Address: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Address { return mutate(accesskey: value) @@ -3038,6 +3298,26 @@ extension Address: GlobalAttributes { public func custom(key: String, value: Any) -> Address { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Address { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Address { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Address { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Address { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Address { + return mutate(key: event.rawValue, value: value) + } } extension Address: AnyContent { @@ -3110,7 +3390,7 @@ public struct Paragraph: ContentNode, HtmlElement, BodyElement, FormElement, Fig } } -extension Paragraph: GlobalAttributes { +extension Paragraph: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Paragraph { return mutate(accesskey: value) @@ -3229,6 +3509,26 @@ extension Paragraph: GlobalAttributes { public func custom(key: String, value: Any) -> Paragraph { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Paragraph { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Paragraph { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Paragraph { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Paragraph { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Paragraph { + return mutate(key: event.rawValue, value: value) + } } extension Paragraph: AnyContent { @@ -3307,7 +3607,7 @@ public struct HorizontalRule: EmptyNode, HtmlElement, BodyElement, FormElement, } } -extension HorizontalRule: GlobalAttributes { +extension HorizontalRule: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> HorizontalRule { return mutate(accesskey: value) @@ -3426,6 +3726,26 @@ extension HorizontalRule: GlobalAttributes { public func custom(key: String, value: Any) -> HorizontalRule { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> HorizontalRule { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> HorizontalRule { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> HorizontalRule { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> HorizontalRule { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> HorizontalRule { + return mutate(key: event.rawValue, value: value) + } } extension HorizontalRule: AnyContent { @@ -3498,7 +3818,7 @@ public struct PreformattedText: ContentNode, HtmlElement, BodyElement, FormEleme } } -extension PreformattedText: GlobalAttributes { +extension PreformattedText: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> PreformattedText { return mutate(accesskey: value) @@ -3617,6 +3937,26 @@ extension PreformattedText: GlobalAttributes { public func custom(key: String, value: Any) -> PreformattedText { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> PreformattedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> PreformattedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> PreformattedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> PreformattedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> PreformattedText { + return mutate(key: event.rawValue, value: value) + } } extension PreformattedText: AnyContent { @@ -3689,7 +4029,7 @@ public struct Blockquote: ContentNode, HtmlElement, BodyElement, FormElement, Fi } } -extension Blockquote: GlobalAttributes, CiteAttribute { +extension Blockquote: GlobalAttributes, GlobalEventAttributes, CiteAttribute { public func accessKey(_ value: Character) -> Blockquote { return mutate(accesskey: value) @@ -3812,6 +4152,26 @@ extension Blockquote: GlobalAttributes, CiteAttribute { public func custom(key: String, value: Any) -> Blockquote { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Blockquote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Blockquote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Blockquote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Blockquote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Blockquote { + return mutate(key: event.rawValue, value: value) + } } extension Blockquote: AnyContent { @@ -3895,7 +4255,7 @@ public struct OrderedList: ContentNode, HtmlElement, BodyElement, FormElement, F } } -extension OrderedList: GlobalAttributes, ReversedAttribute, StartAttribute, TypeAttribute { +extension OrderedList: GlobalAttributes, GlobalEventAttributes, ReversedAttribute, StartAttribute, TypeAttribute { public func accessKey(_ value: Character) -> OrderedList { return mutate(accesskey: value) @@ -4026,6 +4386,26 @@ extension OrderedList: GlobalAttributes, ReversedAttribute, StartAttribute, Type public func custom(key: String, value: Any) -> OrderedList { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> OrderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> OrderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> OrderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> OrderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> OrderedList { + return mutate(key: event.rawValue, value: value) + } } extension OrderedList: AnyContent { @@ -4098,7 +4478,7 @@ public struct UnorderedList: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension UnorderedList: GlobalAttributes { +extension UnorderedList: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> UnorderedList { return mutate(accesskey: value) @@ -4217,6 +4597,26 @@ extension UnorderedList: GlobalAttributes { public func custom(key: String, value: Any) -> UnorderedList { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> UnorderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> UnorderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> UnorderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> UnorderedList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> UnorderedList { + return mutate(key: event.rawValue, value: value) + } } extension UnorderedList: AnyContent { @@ -4289,7 +4689,7 @@ public struct DescriptionList: ContentNode, HtmlElement, BodyElement, FormElemen } } -extension DescriptionList: GlobalAttributes { +extension DescriptionList: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> DescriptionList { return mutate(accesskey: value) @@ -4408,6 +4808,26 @@ extension DescriptionList: GlobalAttributes { public func custom(key: String, value: Any) -> DescriptionList { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> DescriptionList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> DescriptionList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> DescriptionList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> DescriptionList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> DescriptionList { + return mutate(key: event.rawValue, value: value) + } } extension DescriptionList: AnyContent { @@ -4480,7 +4900,7 @@ public struct Figure: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Figure: GlobalAttributes { +extension Figure: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Figure { return mutate(accesskey: value) @@ -4599,6 +5019,26 @@ extension Figure: GlobalAttributes { public func custom(key: String, value: Any) -> Figure { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Figure { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Figure { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Figure { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Figure { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Figure { + return mutate(key: event.rawValue, value: value) + } } extension Figure: AnyContent { @@ -4671,7 +5111,7 @@ public struct Anchor: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Anchor: GlobalAttributes, DownloadAttribute, ReferenceAttribute, ReferenceLanguageAttribute, MediaAttribute, PingAttribute, ReferrerPolicyAttribute, RelationshipAttribute, TargetAttribute, TypeAttribute { +extension Anchor: GlobalAttributes, GlobalEventAttributes, DownloadAttribute, ReferenceAttribute, ReferenceLanguageAttribute, MediaAttribute, PingAttribute, ReferrerPolicyAttribute, RelationshipAttribute, TargetAttribute, TypeAttribute { public func accessKey(_ value: Character) -> Anchor { return mutate(accesskey: value) @@ -4830,6 +5270,26 @@ extension Anchor: GlobalAttributes, DownloadAttribute, ReferenceAttribute, Refer public func custom(key: String, value: Any) -> Anchor { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Anchor { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Anchor { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Anchor { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Anchor { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Anchor { + return mutate(key: event.rawValue, value: value) + } } extension Anchor: AnyContent { @@ -4913,7 +5373,7 @@ public struct Emphasize: ContentNode, HtmlElement, BodyElement, FormElement, Fig } } -extension Emphasize: GlobalAttributes { +extension Emphasize: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Emphasize { return mutate(accesskey: value) @@ -5032,6 +5492,26 @@ extension Emphasize: GlobalAttributes { public func custom(key: String, value: Any) -> Emphasize { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Emphasize { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Emphasize { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Emphasize { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Emphasize { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Emphasize { + return mutate(key: event.rawValue, value: value) + } } extension Emphasize: AnyContent { @@ -5104,7 +5584,7 @@ public struct Strong: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Strong: GlobalAttributes { +extension Strong: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Strong { return mutate(accesskey: value) @@ -5223,6 +5703,26 @@ extension Strong: GlobalAttributes { public func custom(key: String, value: Any) -> Strong { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Strong { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Strong { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Strong { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Strong { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Strong { + return mutate(key: event.rawValue, value: value) + } } extension Strong: AnyContent { @@ -5295,7 +5795,7 @@ public struct Small: ContentNode, HtmlElement, BodyElement, FormElement, FigureE } } -extension Small: GlobalAttributes { +extension Small: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Small { return mutate(accesskey: value) @@ -5414,15 +5914,35 @@ extension Small: GlobalAttributes { public func custom(key: String, value: Any) -> Small { return mutate(key: key, value: value) } -} - -extension Small: AnyContent { - public func prerender(_ formula: Renderer.Formula) throws { - try self.build(formula) + public func on(event: Events.Drag, _ value: String) -> Small { + return mutate(key: event.rawValue, value: value) } - public func render(with manager: Renderer.ContextManager) throws -> String { + public func on(event: Events.Clipboard, _ value: String) -> Small { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Small { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Small { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Small { + return mutate(key: event.rawValue, value: value) + } +} + +extension Small: AnyContent { + + public func prerender(_ formula: Renderer.Formula) throws { + try self.build(formula) + } + + public func render(with manager: Renderer.ContextManager) throws -> String { try self.build(with: manager) } } @@ -5497,7 +6017,7 @@ public struct StrikeThrough: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension StrikeThrough: GlobalAttributes { +extension StrikeThrough: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> StrikeThrough { return mutate(accesskey: value) @@ -5616,6 +6136,26 @@ extension StrikeThrough: GlobalAttributes { public func custom(key: String, value: Any) -> StrikeThrough { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> StrikeThrough { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> StrikeThrough { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> StrikeThrough { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> StrikeThrough { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> StrikeThrough { + return mutate(key: event.rawValue, value: value) + } } extension StrikeThrough: AnyContent { @@ -5699,7 +6239,7 @@ public struct Main: ContentNode, HtmlElement, BodyElement, FormElement { } } -extension Main: GlobalAttributes { +extension Main: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Main { return mutate(accesskey: value) @@ -5818,6 +6358,26 @@ extension Main: GlobalAttributes { public func custom(key: String, value: Any) -> Main { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Main { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Main { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Main { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Main { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Main { + return mutate(key: event.rawValue, value: value) + } } extension Main: AnyContent { @@ -5890,7 +6450,7 @@ public struct Division: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Division: GlobalAttributes { +extension Division: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Division { return mutate(accesskey: value) @@ -6009,6 +6569,26 @@ extension Division: GlobalAttributes { public func custom(key: String, value: Any) -> Division { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Division { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Division { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Division { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Division { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Division { + return mutate(key: event.rawValue, value: value) + } } extension Division: AnyContent { @@ -6081,7 +6661,7 @@ public struct Definition: ContentNode, HtmlElement, BodyElement, FormElement, Fi } } -extension Definition: GlobalAttributes { +extension Definition: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Definition { return mutate(accesskey: value) @@ -6200,6 +6780,26 @@ extension Definition: GlobalAttributes { public func custom(key: String, value: Any) -> Definition { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Definition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Definition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Definition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Definition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Definition { + return mutate(key: event.rawValue, value: value) + } } extension Definition: AnyContent { @@ -6272,7 +6872,7 @@ public struct Cite: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Cite: GlobalAttributes { +extension Cite: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Cite { return mutate(accesskey: value) @@ -6391,6 +6991,26 @@ extension Cite: GlobalAttributes { public func custom(key: String, value: Any) -> Cite { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Cite { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Cite { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Cite { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Cite { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Cite { + return mutate(key: event.rawValue, value: value) + } } extension Cite: AnyContent { @@ -6463,7 +7083,7 @@ public struct ShortQuote: ContentNode, HtmlElement, BodyElement, FormElement, Fi } } -extension ShortQuote: GlobalAttributes, CiteAttribute { +extension ShortQuote: GlobalAttributes, GlobalEventAttributes, CiteAttribute { public func accessKey(_ value: Character) -> ShortQuote { return mutate(accesskey: value) @@ -6586,6 +7206,26 @@ extension ShortQuote: GlobalAttributes, CiteAttribute { public func custom(key: String, value: Any) -> ShortQuote { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> ShortQuote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> ShortQuote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> ShortQuote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> ShortQuote { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> ShortQuote { + return mutate(key: event.rawValue, value: value) + } } extension ShortQuote: AnyContent { @@ -6658,7 +7298,7 @@ public struct Abbreviation: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension Abbreviation: GlobalAttributes { +extension Abbreviation: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Abbreviation { return mutate(accesskey: value) @@ -6777,6 +7417,26 @@ extension Abbreviation: GlobalAttributes { public func custom(key: String, value: Any) -> Abbreviation { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Abbreviation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Abbreviation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Abbreviation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Abbreviation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Abbreviation { + return mutate(key: event.rawValue, value: value) + } } extension Abbreviation: AnyContent { @@ -6849,7 +7509,7 @@ public struct Ruby: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Ruby: GlobalAttributes { +extension Ruby: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Ruby { return mutate(accesskey: value) @@ -6968,6 +7628,26 @@ extension Ruby: GlobalAttributes { public func custom(key: String, value: Any) -> Ruby { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Ruby { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Ruby { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Ruby { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Ruby { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Ruby { + return mutate(key: event.rawValue, value: value) + } } extension Ruby: AnyContent { @@ -7040,7 +7720,7 @@ public struct Data: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Data: GlobalAttributes, ValueAttribute { +extension Data: GlobalAttributes, GlobalEventAttributes, ValueAttribute { public func accessKey(_ value: Character) -> Data { return mutate(accesskey: value) @@ -7167,6 +7847,26 @@ extension Data: GlobalAttributes, ValueAttribute { public func custom(key: String, value: Any) -> Data { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Data { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Data { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Data { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Data { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Data { + return mutate(key: event.rawValue, value: value) + } } extension Data: AnyContent { @@ -7239,7 +7939,7 @@ public struct Time: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Time: GlobalAttributes, DateTimeAttribute { +extension Time: GlobalAttributes, GlobalEventAttributes, DateTimeAttribute { public func accessKey(_ value: Character) -> Time { return mutate(accesskey: value) @@ -7362,6 +8062,26 @@ extension Time: GlobalAttributes, DateTimeAttribute { public func custom(key: String, value: Any) -> Time { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Time { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Time { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Time { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Time { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Time { + return mutate(key: event.rawValue, value: value) + } } extension Time: AnyContent { @@ -7434,7 +8154,7 @@ public struct Code: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Code: GlobalAttributes { +extension Code: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Code { return mutate(accesskey: value) @@ -7553,6 +8273,26 @@ extension Code: GlobalAttributes { public func custom(key: String, value: Any) -> Code { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Code { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Code { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Code { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Code { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Code { + return mutate(key: event.rawValue, value: value) + } } extension Code: AnyContent { @@ -7625,7 +8365,7 @@ public struct Variable: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Variable: GlobalAttributes { +extension Variable: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Variable { return mutate(accesskey: value) @@ -7744,6 +8484,26 @@ extension Variable: GlobalAttributes { public func custom(key: String, value: Any) -> Variable { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Variable { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Variable { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Variable { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Variable { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Variable { + return mutate(key: event.rawValue, value: value) + } } extension Variable: AnyContent { @@ -7816,7 +8576,7 @@ public struct SampleOutput: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension SampleOutput: GlobalAttributes { +extension SampleOutput: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> SampleOutput { return mutate(accesskey: value) @@ -7935,6 +8695,26 @@ extension SampleOutput: GlobalAttributes { public func custom(key: String, value: Any) -> SampleOutput { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> SampleOutput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> SampleOutput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> SampleOutput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> SampleOutput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> SampleOutput { + return mutate(key: event.rawValue, value: value) + } } extension SampleOutput: AnyContent { @@ -8007,7 +8787,7 @@ public struct KeyboardInput: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension KeyboardInput: GlobalAttributes { +extension KeyboardInput: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> KeyboardInput { return mutate(accesskey: value) @@ -8126,6 +8906,26 @@ extension KeyboardInput: GlobalAttributes { public func custom(key: String, value: Any) -> KeyboardInput { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> KeyboardInput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> KeyboardInput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> KeyboardInput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> KeyboardInput { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> KeyboardInput { + return mutate(key: event.rawValue, value: value) + } } extension KeyboardInput: AnyContent { @@ -8198,7 +8998,7 @@ public struct Subscript: ContentNode, HtmlElement, BodyElement, FormElement, Fig } } -extension Subscript: GlobalAttributes { +extension Subscript: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Subscript { return mutate(accesskey: value) @@ -8317,6 +9117,26 @@ extension Subscript: GlobalAttributes { public func custom(key: String, value: Any) -> Subscript { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Subscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Subscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Subscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Subscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Subscript { + return mutate(key: event.rawValue, value: value) + } } extension Subscript: AnyContent { @@ -8389,7 +9209,7 @@ public struct Superscript: ContentNode, HtmlElement, BodyElement, FormElement, F } } -extension Superscript: GlobalAttributes { +extension Superscript: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Superscript { return mutate(accesskey: value) @@ -8508,6 +9328,26 @@ extension Superscript: GlobalAttributes { public func custom(key: String, value: Any) -> Superscript { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Superscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Superscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Superscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Superscript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Superscript { + return mutate(key: event.rawValue, value: value) + } } extension Superscript: AnyContent { @@ -8580,7 +9420,7 @@ public struct Italic: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Italic: GlobalAttributes { +extension Italic: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Italic { return mutate(accesskey: value) @@ -8699,6 +9539,26 @@ extension Italic: GlobalAttributes { public func custom(key: String, value: Any) -> Italic { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Italic { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Italic { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Italic { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Italic { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Italic { + return mutate(key: event.rawValue, value: value) + } } extension Italic: Localizable { @@ -8782,7 +9642,7 @@ public struct Bold: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Bold: GlobalAttributes { +extension Bold: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Bold { return mutate(accesskey: value) @@ -8901,6 +9761,26 @@ extension Bold: GlobalAttributes { public func custom(key: String, value: Any) -> Bold { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Bold { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Bold { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Bold { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Bold { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Bold { + return mutate(key: event.rawValue, value: value) + } } extension Bold: Localizable { @@ -8984,7 +9864,7 @@ public struct Underline: ContentNode, HtmlElement, BodyElement, FormElement, Fig } } -extension Underline: GlobalAttributes { +extension Underline: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Underline { return mutate(accesskey: value) @@ -9103,6 +9983,26 @@ extension Underline: GlobalAttributes { public func custom(key: String, value: Any) -> Underline { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Underline { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Underline { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Underline { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Underline { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Underline { + return mutate(key: event.rawValue, value: value) + } } extension Underline: Localizable { @@ -9186,7 +10086,7 @@ public struct Mark: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Mark: GlobalAttributes { +extension Mark: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Mark { return mutate(accesskey: value) @@ -9305,6 +10205,26 @@ extension Mark: GlobalAttributes { public func custom(key: String, value: Any) -> Mark { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Mark { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Mark { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Mark { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Mark { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Mark { + return mutate(key: event.rawValue, value: value) + } } extension Mark: AnyContent { @@ -9377,7 +10297,7 @@ public struct Bdi: ContentNode, HtmlElement, BodyElement, FormElement, FigureEle } } -extension Bdi: GlobalAttributes { +extension Bdi: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Bdi { return mutate(accesskey: value) @@ -9496,6 +10416,26 @@ extension Bdi: GlobalAttributes { public func custom(key: String, value: Any) -> Bdi { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Bdi { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Bdi { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Bdi { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Bdi { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Bdi { + return mutate(key: event.rawValue, value: value) + } } extension Bdi: AnyContent { @@ -9563,7 +10503,7 @@ public struct Bdo: EmptyNode, HtmlElement, BodyElement, FormElement, FigureEleme } } -extension Bdo: GlobalAttributes { +extension Bdo: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Bdo { return mutate(accesskey: value) @@ -9682,6 +10622,26 @@ extension Bdo: GlobalAttributes { public func custom(key: String, value: Any) -> Bdo { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Bdo { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Bdo { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Bdo { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Bdo { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Bdo { + return mutate(key: event.rawValue, value: value) + } } extension Bdo: AnyContent { @@ -9754,7 +10714,7 @@ public struct Span: ContentNode, HtmlElement, BodyElement, FormElement, FigureEl } } -extension Span: GlobalAttributes { +extension Span: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Span { return mutate(accesskey: value) @@ -9873,6 +10833,26 @@ extension Span: GlobalAttributes { public func custom(key: String, value: Any) -> Span { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Span { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Span { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Span { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Span { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Span { + return mutate(key: event.rawValue, value: value) + } } extension Span: AnyContent { @@ -9940,7 +10920,7 @@ public struct LineBreak: EmptyNode, HtmlElement, BodyElement, FormElement, Figur } } -extension LineBreak: GlobalAttributes { +extension LineBreak: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> LineBreak { return mutate(accesskey: value) @@ -10059,6 +11039,26 @@ extension LineBreak: GlobalAttributes { public func custom(key: String, value: Any) -> LineBreak { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> LineBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> LineBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> LineBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> LineBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> LineBreak { + return mutate(key: event.rawValue, value: value) + } } extension LineBreak: AnyContent { @@ -10126,7 +11126,7 @@ public struct WordBreak: EmptyNode, HtmlElement, BodyElement, FormElement, Figur } } -extension WordBreak: GlobalAttributes { +extension WordBreak: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> WordBreak { return mutate(accesskey: value) @@ -10245,6 +11245,26 @@ extension WordBreak: GlobalAttributes { public func custom(key: String, value: Any) -> WordBreak { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> WordBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> WordBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> WordBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> WordBreak { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> WordBreak { + return mutate(key: event.rawValue, value: value) + } } extension WordBreak: AnyContent { @@ -10317,7 +11337,7 @@ public struct InsertedText: ContentNode, HtmlElement, BodyElement, FormElement, } } -extension InsertedText: GlobalAttributes, CiteAttribute, DateTimeAttribute { +extension InsertedText: GlobalAttributes, GlobalEventAttributes, CiteAttribute, DateTimeAttribute { public func accessKey(_ value: Character) -> InsertedText { return mutate(accesskey: value) @@ -10444,6 +11464,26 @@ extension InsertedText: GlobalAttributes, CiteAttribute, DateTimeAttribute { public func custom(key: String, value: Any) -> InsertedText { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> InsertedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> InsertedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> InsertedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> InsertedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> InsertedText { + return mutate(key: event.rawValue, value: value) + } } extension InsertedText: AnyContent { @@ -10516,7 +11556,7 @@ public struct DeletedText: ContentNode, HtmlElement, BodyElement, FormElement, F } } -extension DeletedText: GlobalAttributes, CiteAttribute, DateTimeAttribute { +extension DeletedText: GlobalAttributes, GlobalEventAttributes, CiteAttribute, DateTimeAttribute { public func accessKey(_ value: Character) -> DeletedText { return mutate(accesskey: value) @@ -10643,6 +11683,26 @@ extension DeletedText: GlobalAttributes, CiteAttribute, DateTimeAttribute { public func custom(key: String, value: Any) -> DeletedText { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> DeletedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> DeletedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> DeletedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> DeletedText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> DeletedText { + return mutate(key: event.rawValue, value: value) + } } extension DeletedText: AnyContent { @@ -10715,7 +11775,7 @@ public struct Picture: ContentNode, HtmlElement, BodyElement, FormElement, Figur } } -extension Picture: GlobalAttributes { +extension Picture: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Picture { return mutate(accesskey: value) @@ -10834,6 +11894,26 @@ extension Picture: GlobalAttributes { public func custom(key: String, value: Any) -> Picture { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Picture { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Picture { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Picture { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Picture { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Picture { + return mutate(key: event.rawValue, value: value) + } } extension Picture: AnyContent { @@ -10901,15 +11981,7 @@ public struct Image: EmptyNode, HtmlElement, BodyElement, FormElement, FigureEle } } -extension Image: GlobalAttributes, AlternateAttribute, SourceAttribute, SizesAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute, ErrorEventAttribute, LoadEventAttribute { - - public func onError(_ value: String) -> Image { - return mutate(onerror: value) - } - - public func onLoad(_ value: String) -> Image { - return mutate(onload: value) - } +extension Image: GlobalAttributes, GlobalEventAttributes, AlternateAttribute, SourceAttribute, SizesAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute { public func accessKey(_ value: Character) -> Image { return mutate(accesskey: value) @@ -11052,6 +12124,26 @@ extension Image: GlobalAttributes, AlternateAttribute, SourceAttribute, SizesAtt public func custom(key: String, value: Any) -> Image { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Image { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Image { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Image { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Image { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Image { + return mutate(key: event.rawValue, value: value) + } } extension Image: AnyContent { @@ -11124,7 +12216,7 @@ public struct InlineFrame: ContentNode, HtmlElement, BodyElement, FormElement, F } } -extension InlineFrame: GlobalAttributes, SourceAttribute, NameAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute { +extension InlineFrame: GlobalAttributes, GlobalEventAttributes, SourceAttribute, NameAttribute, WidthAttribute, HeightAttribute, ReferrerPolicyAttribute { public func accessKey(_ value: Character) -> InlineFrame { return mutate(accesskey: value) @@ -11267,6 +12359,26 @@ extension InlineFrame: GlobalAttributes, SourceAttribute, NameAttribute, WidthAt public func custom(key: String, value: Any) -> InlineFrame { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> InlineFrame { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> InlineFrame { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> InlineFrame { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> InlineFrame { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> InlineFrame { + return mutate(key: event.rawValue, value: value) + } } extension InlineFrame: AnyContent { @@ -11334,7 +12446,7 @@ public struct Embed: EmptyNode, HtmlElement, BodyElement, FormElement, FigureEle } } -extension Embed: GlobalAttributes, SourceAttribute, TypeAttribute, WidthAttribute, HeightAttribute { +extension Embed: GlobalAttributes, GlobalEventAttributes, SourceAttribute, TypeAttribute, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> Embed { return mutate(accesskey: value) @@ -11469,6 +12581,26 @@ extension Embed: GlobalAttributes, SourceAttribute, TypeAttribute, WidthAttribut public func custom(key: String, value: Any) -> Embed { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Embed { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Embed { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Embed { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Embed { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Embed { + return mutate(key: event.rawValue, value: value) + } } extension Embed: AnyContent { @@ -11541,11 +12673,7 @@ public struct Object: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Object: GlobalAttributes, DataAttribute, TypeAttribute, NameAttribute, FormAttribute, WidthAttribute, HeightAttribute, ErrorEventAttribute { - - public func onError(_ value: String) -> Object { - return mutate(onerror: value) - } +extension Object: GlobalAttributes, GlobalEventAttributes, DataAttribute, TypeAttribute, NameAttribute, FormAttribute, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> Object { return mutate(accesskey: value) @@ -11692,6 +12820,26 @@ extension Object: GlobalAttributes, DataAttribute, TypeAttribute, NameAttribute, public func custom(key: String, value: Any) -> Object { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Object { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Object { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Object { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Object { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Object { + return mutate(key: event.rawValue, value: value) + } } extension Object: AnyContent { @@ -11764,7 +12912,7 @@ public struct Video: ContentNode, HtmlElement, BodyElement, FormElement, FigureE } } -extension Video: GlobalAttributes, SourceAttribute, AutoplayAttribute, LoopAttribute, MutedAttribute, ControlsAttribute, WidthAttribute, HeightAttribute, PreloadAttribute { +extension Video: GlobalAttributes, GlobalEventAttributes, SourceAttribute, AutoplayAttribute, LoopAttribute, MutedAttribute, ControlsAttribute, WidthAttribute, HeightAttribute, PreloadAttribute { public func accessKey(_ value: Character) -> Video { return mutate(accesskey: value) @@ -11915,6 +13063,26 @@ extension Video: GlobalAttributes, SourceAttribute, AutoplayAttribute, LoopAttri public func custom(key: String, value: Any) -> Video { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Video { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Video { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Video { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Video { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Video { + return mutate(key: event.rawValue, value: value) + } } extension Video: AnyContent { @@ -11987,7 +13155,7 @@ public struct Audio: ContentNode, HtmlElement, BodyElement, FormElement, FigureE } } -extension Audio: GlobalAttributes, SourceAttribute, AutoplayAttribute, LoopAttribute, MutedAttribute, ControlsAttribute, PreloadAttribute { +extension Audio: GlobalAttributes, GlobalEventAttributes, SourceAttribute, AutoplayAttribute, LoopAttribute, MutedAttribute, ControlsAttribute, PreloadAttribute { public func accessKey(_ value: Character) -> Audio { return mutate(accesskey: value) @@ -12130,6 +13298,26 @@ extension Audio: GlobalAttributes, SourceAttribute, AutoplayAttribute, LoopAttri public func custom(key: String, value: Any) -> Audio { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Audio { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Audio { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Audio { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Audio { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Audio { + return mutate(key: event.rawValue, value: value) + } } extension Audio: AnyContent { @@ -12202,7 +13390,7 @@ public struct Map: ContentNode, HtmlElement, BodyElement, FormElement, FigureEle } } -extension Map: GlobalAttributes, NameAttribute { +extension Map: GlobalAttributes, GlobalEventAttributes, NameAttribute { public func accessKey(_ value: Character) -> Map { return mutate(accesskey: value) @@ -12329,6 +13517,26 @@ extension Map: GlobalAttributes, NameAttribute { public func custom(key: String, value: Any) -> Map { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Map { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Map { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Map { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Map { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Map { + return mutate(key: event.rawValue, value: value) + } } extension Map: AnyContent { @@ -12401,15 +13609,7 @@ public struct Form: ContentNode, HtmlElement, BodyElement, FigureElement, Object } } -extension Form: GlobalAttributes, ActionAttribute, AutocompleteAttribute, EncodingAttribute, MethodAttribute, NameAttribute, TargetAttribute, RelationshipAttribute, ResetEventAttribute, SubmitEventAttribute { - - public func onReset(_ value: String) -> Form { - return mutate(onreset: value) - } - - public func onSubmit(_ value: String) -> Form { - return mutate(onsubmit: value) - } +extension Form: GlobalAttributes, GlobalEventAttributes, ActionAttribute, AutocompleteAttribute, EncodingAttribute, MethodAttribute, NameAttribute, TargetAttribute, RelationshipAttribute { public func accessKey(_ value: Character) -> Form { return mutate(accesskey: value) @@ -12560,6 +13760,26 @@ extension Form: GlobalAttributes, ActionAttribute, AutocompleteAttribute, Encodi public func custom(key: String, value: Any) -> Form { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Form { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Form { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Form { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Form { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Form { + return mutate(key: event.rawValue, value: value) + } } extension Form: AnyContent { @@ -12632,7 +13852,7 @@ public struct DataList: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension DataList: GlobalAttributes { +extension DataList: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> DataList { return mutate(accesskey: value) @@ -12751,6 +13971,26 @@ extension DataList: GlobalAttributes { public func custom(key: String, value: Any) -> DataList { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> DataList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> DataList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> DataList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> DataList { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> DataList { + return mutate(key: event.rawValue, value: value) + } } extension DataList: AnyContent { @@ -12823,7 +14063,7 @@ public struct Output: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Output: GlobalAttributes, ForAttribute, FormAttribute, NameAttribute { +extension Output: GlobalAttributes, GlobalEventAttributes, ForAttribute, FormAttribute, NameAttribute { public func accessKey(_ value: Character) -> Output { return mutate(accesskey: value) @@ -12958,6 +14198,26 @@ extension Output: GlobalAttributes, ForAttribute, FormAttribute, NameAttribute { public func custom(key: String, value: Any) -> Output { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Output { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Output { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Output { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Output { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Output { + return mutate(key: event.rawValue, value: value) + } } extension Output: AnyContent { @@ -13030,7 +14290,7 @@ public struct Progress: ContentNode, HtmlElement, BodyElement, FormElement, Figu } } -extension Progress: GlobalAttributes, ValueAttribute, MaximumValueAttribute { +extension Progress: GlobalAttributes, GlobalEventAttributes, ValueAttribute, MaximumValueAttribute { public func accessKey(_ value: Character) -> Progress { return mutate(accesskey: value) @@ -13161,6 +14421,26 @@ extension Progress: GlobalAttributes, ValueAttribute, MaximumValueAttribute { public func custom(key: String, value: Any) -> Progress { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Progress { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Progress { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Progress { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Progress { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Progress { + return mutate(key: event.rawValue, value: value) + } } extension Progress: AnyContent { @@ -13233,7 +14513,7 @@ public struct Meter: ContentNode, HtmlElement, BodyElement, FormElement, FigureE } } -extension Meter: GlobalAttributes, ValueAttribute, MinimumValueAttribute, MaximumValueAttribute, LowAttribute, HighAttribute, OptimumAttribute { +extension Meter: GlobalAttributes, GlobalEventAttributes, ValueAttribute, MinimumValueAttribute, MaximumValueAttribute, LowAttribute, HighAttribute, OptimumAttribute { public func accessKey(_ value: Character) -> Meter { return mutate(accesskey: value) @@ -13380,6 +14660,26 @@ extension Meter: GlobalAttributes, ValueAttribute, MinimumValueAttribute, Maximu public func custom(key: String, value: Any) -> Meter { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Meter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Meter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Meter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Meter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Meter { + return mutate(key: event.rawValue, value: value) + } } extension Meter: AnyContent { @@ -13452,11 +14752,7 @@ public struct Details: ContentNode, HtmlElement, BodyElement, FormElement, Figur } } -extension Details: GlobalAttributes, OpenAttribute, ToggleEventAttribute { - - public func onToggle(_ value: String) -> Details { - return mutate(ontoggle: value) - } +extension Details: GlobalAttributes, GlobalEventAttributes, OpenAttribute, DetailEventAttribute { public func accessKey(_ value: Character) -> Details { return mutate(accesskey: value) @@ -13579,6 +14875,30 @@ extension Details: GlobalAttributes, OpenAttribute, ToggleEventAttribute { public func custom(key: String, value: Any) -> Details { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Details { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Details { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Details { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Details { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Details { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Detail, _ value: String) -> Details { + return mutate(key: event.rawValue, value: value) + } } extension Details: AnyContent { @@ -13647,7 +14967,7 @@ public struct Dialog: ContentNode, BodyElement { } } -extension Dialog: GlobalAttributes, OpenAttribute { +extension Dialog: GlobalAttributes, GlobalEventAttributes, OpenAttribute { public func accessKey(_ value: Character) -> Dialog { return mutate(accesskey: value) @@ -13770,6 +15090,26 @@ extension Dialog: GlobalAttributes, OpenAttribute { public func custom(key: String, value: Any) -> Dialog { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Dialog { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Dialog { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Dialog { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Dialog { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Dialog { + return mutate(key: event.rawValue, value: value) + } } extension Dialog: AnyContent { @@ -13842,15 +15182,7 @@ public struct Script: ContentNode, HeadElement, BodyElement, FormElement, Figure } } -extension Script: GlobalAttributes, AsynchronouslyAttribute, ReferrerPolicyAttribute, SourceAttribute, TypeAttribute, ErrorEventAttribute, LoadEventAttribute { - - public func onError(_ value: String) -> Script { - return mutate(onerror: value) - } - - public func onLoad(_ value: String) -> Script { - return mutate(onload: value) - } +extension Script: GlobalAttributes, GlobalEventAttributes, AsynchronouslyAttribute, ReferrerPolicyAttribute, SourceAttribute, TypeAttribute { public func accessKey(_ value: Character) -> Script { return mutate(accesskey: value) @@ -13985,6 +15317,26 @@ extension Script: GlobalAttributes, AsynchronouslyAttribute, ReferrerPolicyAttri public func custom(key: String, value: Any) -> Script { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Script { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Script { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Script { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Script { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Script { + return mutate(key: event.rawValue, value: value) + } } extension Script: AnyContent { @@ -14057,7 +15409,7 @@ public struct NoScript: ContentNode, HtmlElement, HeadElement, BodyElement, Form } } -extension NoScript: GlobalAttributes { +extension NoScript: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> NoScript { return mutate(accesskey: value) @@ -14176,6 +15528,26 @@ extension NoScript: GlobalAttributes { public func custom(key: String, value: Any) -> NoScript { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> NoScript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> NoScript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> NoScript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> NoScript { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> NoScript { + return mutate(key: event.rawValue, value: value) + } } extension NoScript: AnyContent { @@ -14248,7 +15620,7 @@ public struct Template: ContentNode, BodyElement, FormElement, FigureElement, Ob } } -extension Template: GlobalAttributes { +extension Template: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Template { return mutate(accesskey: value) @@ -14367,6 +15739,26 @@ extension Template: GlobalAttributes { public func custom(key: String, value: Any) -> Template { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Template { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Template { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Template { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Template { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Template { + return mutate(key: event.rawValue, value: value) + } } extension Template: AnyContent { @@ -14439,7 +15831,7 @@ public struct Canvas: ContentNode, HtmlElement, BodyElement, FormElement, Figure } } -extension Canvas: GlobalAttributes, WidthAttribute, HeightAttribute { +extension Canvas: GlobalAttributes, GlobalEventAttributes, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> Canvas { return mutate(accesskey: value) @@ -14566,6 +15958,26 @@ extension Canvas: GlobalAttributes, WidthAttribute, HeightAttribute { public func custom(key: String, value: Any) -> Canvas { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Canvas { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Canvas { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Canvas { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Canvas { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Canvas { + return mutate(key: event.rawValue, value: value) + } } extension Canvas: AnyContent { @@ -14638,7 +16050,7 @@ public struct Table: ContentNode, HtmlElement, BodyElement, FormElement, FigureE } } -extension Table: GlobalAttributes, WidthAttribute, HeightAttribute { +extension Table: GlobalAttributes, GlobalEventAttributes, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> Table { return mutate(accesskey: value) @@ -14765,6 +16177,26 @@ extension Table: GlobalAttributes, WidthAttribute, HeightAttribute { public func custom(key: String, value: Any) -> Table { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Table { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Table { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Table { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Table { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Table { + return mutate(key: event.rawValue, value: value) + } } extension Table: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/DefinitionElements.swift b/Sources/HTMLKit/External/Elements/DefinitionElements.swift index ff0e2441..96805370 100644 --- a/Sources/HTMLKit/External/Elements/DefinitionElements.swift +++ b/Sources/HTMLKit/External/Elements/DefinitionElements.swift @@ -55,7 +55,7 @@ public struct TermName: ContentNode, DescriptionElement { } } -extension TermName: GlobalAttributes { +extension TermName: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> TermName { return mutate(accesskey: value) @@ -174,6 +174,26 @@ extension TermName: GlobalAttributes { public func custom(key: String, value: Any) -> TermName { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TermName { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TermName { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TermName { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TermName { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TermName { + return mutate(key: event.rawValue, value: value) + } } extension TermName: AnyContent { @@ -246,7 +266,7 @@ public struct TermDefinition: ContentNode, DescriptionElement { } } -extension TermDefinition: GlobalAttributes { +extension TermDefinition: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> TermDefinition { return mutate(accesskey: value) @@ -365,6 +385,26 @@ extension TermDefinition: GlobalAttributes { public func custom(key: String, value: Any) -> TermDefinition { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TermDefinition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TermDefinition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TermDefinition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TermDefinition { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TermDefinition { + return mutate(key: event.rawValue, value: value) + } } extension TermDefinition: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/FigureElements.swift b/Sources/HTMLKit/External/Elements/FigureElements.swift index 9012b0e5..8b440837 100644 --- a/Sources/HTMLKit/External/Elements/FigureElements.swift +++ b/Sources/HTMLKit/External/Elements/FigureElements.swift @@ -46,7 +46,7 @@ public struct FigureCaption: ContentNode, FigureElement { } } -extension FigureCaption: GlobalAttributes { +extension FigureCaption: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> FigureCaption { return mutate(accesskey: value) @@ -165,6 +165,26 @@ extension FigureCaption: GlobalAttributes { public func custom(key: String, value: Any) -> FigureCaption { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> FigureCaption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> FigureCaption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> FigureCaption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> FigureCaption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> FigureCaption { + return mutate(key: event.rawValue, value: value) + } } extension FigureCaption: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/FormElements.swift b/Sources/HTMLKit/External/Elements/FormElements.swift index 375caf83..8495f00e 100644 --- a/Sources/HTMLKit/External/Elements/FormElements.swift +++ b/Sources/HTMLKit/External/Elements/FormElements.swift @@ -32,11 +32,7 @@ public struct Input: EmptyNode, FormElement { } } -extension Input: GlobalAttributes, AcceptAttribute, AlternateAttribute, AutocompleteAttribute, CheckedAttribute, DisabledAttribute, FormAttribute, FormActionAttribute, HeightAttribute, ListAttribute, MaximumValueAttribute, MaximumLengthAttribute, MinimumValueAttribute, MinimumLengthAttribute, MultipleAttribute, NameAttribute, PatternAttribute, PlaceholderAttribute, ReadyOnlyAttribute, RequiredAttribute, SizeAttribute, SourceAttribute, StepAttribute, TypeAttribute, ValueAttribute, WidthAttribute, InvalidEventAttribute { - - public func onInvalid(_ value: String) -> Input { - return mutate(oninvalid: value) - } +extension Input: GlobalAttributes, GlobalEventAttributes, AcceptAttribute, AlternateAttribute, AutocompleteAttribute, CheckedAttribute, DisabledAttribute, FormAttribute, FormActionAttribute, HeightAttribute, ListAttribute, MaximumValueAttribute, MaximumLengthAttribute, MinimumValueAttribute, MinimumLengthAttribute, MultipleAttribute, NameAttribute, PatternAttribute, PlaceholderAttribute, ReadyOnlyAttribute, RequiredAttribute, SizeAttribute, SourceAttribute, StepAttribute, TypeAttribute, ValueAttribute, WidthAttribute { public func accessKey(_ value: Character) -> Input { return mutate(accesskey: value) @@ -267,6 +263,26 @@ extension Input: GlobalAttributes, AcceptAttribute, AlternateAttribute, Autocomp public func custom(key: String, value: Any) -> Input { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Input { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Input { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Input { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Input { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Input { + return mutate(key: event.rawValue, value: value) + } } extension Input: AnyContent { @@ -339,7 +355,7 @@ public struct Label: ContentNode, FormElement { } } -extension Label: GlobalAttributes, ForAttribute { +extension Label: GlobalAttributes, GlobalEventAttributes, ForAttribute { public func accessKey(_ value: Character) -> Label { return mutate(accesskey: value) @@ -462,6 +478,26 @@ extension Label: GlobalAttributes, ForAttribute { public func custom(key: String, value: Any) -> Label { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Label { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Label { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Label { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Label { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Label { + return mutate(key: event.rawValue, value: value) + } } extension Label: AnyContent { @@ -545,8 +581,8 @@ public struct Select: ContentNode, FormElement { } } -extension Select: GlobalAttributes, AutocompleteAttribute, DisabledAttribute, FormAttribute, MultipleAttribute, NameAttribute, RequiredAttribute, SizeAttribute { - +extension Select: GlobalAttributes, GlobalEventAttributes, AutocompleteAttribute, DisabledAttribute, FormAttribute, MultipleAttribute, NameAttribute, RequiredAttribute, SizeAttribute { + public func accessKey(_ value: Character) -> Select { return mutate(accesskey: value) } @@ -696,6 +732,26 @@ extension Select: GlobalAttributes, AutocompleteAttribute, DisabledAttribute, Fo public func custom(key: String, value: Any) -> Select { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Select { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Select { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Select { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Select { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Select { + return mutate(key: event.rawValue, value: value) + } } extension Select: AnyContent { @@ -768,7 +824,7 @@ public struct TextArea: ContentNode, FormElement { } } -extension TextArea: GlobalAttributes, AutocompleteAttribute, ColumnsAttribute, DisabledAttribute, FormAttribute, MaximumLengthAttribute, MinimumLengthAttribute, NameAttribute, PlaceholderAttribute, ReadyOnlyAttribute, RequiredAttribute, RowsAttribute, WrapAttribute { +extension TextArea: GlobalAttributes, GlobalEventAttributes, AutocompleteAttribute, ColumnsAttribute, DisabledAttribute, FormAttribute, MaximumLengthAttribute, MinimumLengthAttribute, NameAttribute, PlaceholderAttribute, ReadyOnlyAttribute, RequiredAttribute, RowsAttribute, WrapAttribute { public func accessKey(_ value: Character) -> TextArea { return mutate(accesskey: value) @@ -943,6 +999,26 @@ extension TextArea: GlobalAttributes, AutocompleteAttribute, ColumnsAttribute, D public func custom(key: String, value: Any) -> TextArea { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TextArea { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TextArea { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TextArea { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TextArea { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TextArea { + return mutate(key: event.rawValue, value: value) + } } extension TextArea: AnyContent { @@ -1015,7 +1091,7 @@ public struct Button: ContentNode, FormElement { } } -extension Button: GlobalAttributes, DisabledAttribute, FormAttribute, FormActionAttribute, NameAttribute, TypeAttribute, ValueAttribute { +extension Button: GlobalAttributes, GlobalEventAttributes, DisabledAttribute, FormAttribute, FormActionAttribute, NameAttribute, TypeAttribute, ValueAttribute { public func accessKey(_ value: Character) -> Button { return mutate(accesskey: value) @@ -1166,6 +1242,26 @@ extension Button: GlobalAttributes, DisabledAttribute, FormAttribute, FormAction public func custom(key: String, value: Any) -> Button { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Button { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Button { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Button { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Button { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Button { + return mutate(key: event.rawValue, value: value) + } } extension Button: AnyContent { @@ -1249,7 +1345,7 @@ public struct Fieldset: ContentNode, FormElement { } } -extension Fieldset: GlobalAttributes, DisabledAttribute, FormAttribute, NameAttribute { +extension Fieldset: GlobalAttributes, GlobalEventAttributes, DisabledAttribute, FormAttribute, NameAttribute { public func accessKey(_ value: Character) -> Fieldset { return mutate(accesskey: value) @@ -1384,6 +1480,26 @@ extension Fieldset: GlobalAttributes, DisabledAttribute, FormAttribute, NameAttr public func custom(key: String, value: Any) -> Fieldset { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Fieldset { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Fieldset { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Fieldset { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Fieldset { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Fieldset { + return mutate(key: event.rawValue, value: value) + } } extension Fieldset: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/HeadElements.swift b/Sources/HTMLKit/External/Elements/HeadElements.swift index ad6d5829..0f739b64 100644 --- a/Sources/HTMLKit/External/Elements/HeadElements.swift +++ b/Sources/HTMLKit/External/Elements/HeadElements.swift @@ -37,7 +37,7 @@ public struct Title: ContentNode, HeadElement { } } -extension Title: GlobalAttributes { +extension Title: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Title { return mutate(accesskey: value) @@ -156,6 +156,26 @@ extension Title: GlobalAttributes { public func custom(key: String, value: Any) -> Title { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Title { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Title { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Title { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Title { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Title { + return mutate(key: event.rawValue, value: value) + } } extension Title: AnyContent { @@ -223,7 +243,7 @@ public struct Base: EmptyNode, HeadElement { } } -extension Base: GlobalAttributes, ReferenceAttribute, TargetAttribute { +extension Base: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, TargetAttribute { public func accessKey(_ value: Character) -> Base { return mutate(accesskey: value) @@ -354,6 +374,26 @@ extension Base: GlobalAttributes, ReferenceAttribute, TargetAttribute { public func custom(key: String, value: Any) -> Base { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Base { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Base { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Base { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Base { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Base { + return mutate(key: event.rawValue, value: value) + } } extension Base: AnyContent { @@ -421,7 +461,7 @@ public struct Meta: EmptyNode, HeadElement { } } -extension Meta: GlobalAttributes, ContentAttribute, NameAttribute, PropertyAttribute, CharsetAttribute, EquivalentAttribute { +extension Meta: GlobalAttributes, GlobalEventAttributes, ContentAttribute, NameAttribute, PropertyAttribute, CharsetAttribute, EquivalentAttribute { public func accessKey(_ value: Character) -> Meta { return mutate(accesskey: value) @@ -568,6 +608,26 @@ extension Meta: GlobalAttributes, ContentAttribute, NameAttribute, PropertyAttri public func custom(key: String, value: Any) -> Meta { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Meta { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Meta { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Meta { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Meta { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Meta { + return mutate(key: event.rawValue, value: value) + } } extension Meta: AnyContent { @@ -640,11 +700,7 @@ public struct Style: ContentNode, HeadElement { } } -extension Style: GlobalAttributes, TypeAttribute, MediaAttribute, LoadEventAttribute { - - public func onLoad(_ value: String) -> Style { - return mutate(onload: value) - } +extension Style: GlobalAttributes, GlobalEventAttributes, TypeAttribute, MediaAttribute { public func accessKey(_ value: Character) -> Style { return mutate(accesskey: value) @@ -771,6 +827,26 @@ extension Style: GlobalAttributes, TypeAttribute, MediaAttribute, LoadEventAttri public func custom(key: String, value: Any) -> Style { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Style { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Style { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Style { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Style { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Style { + return mutate(key: event.rawValue, value: value) + } } extension Style: AnyContent { @@ -838,15 +914,7 @@ public struct Link: EmptyNode, HeadElement { } } -extension Link: GlobalAttributes, ReferenceAttribute, ReferenceLanguageAttribute, MediaAttribute, ReferrerPolicyAttribute, RelationshipAttribute, SizesAttribute, TypeAttribute, ErrorEventAttribute, LoadEventAttribute { - - public func onError(_ value: String) -> Link { - return mutate(onerror: value) - } - - public func onLoad(_ value: String) -> Link { - return mutate(onload: value) - } +extension Link: GlobalAttributes, GlobalEventAttributes, ReferenceAttribute, ReferenceLanguageAttribute, MediaAttribute, ReferrerPolicyAttribute, RelationshipAttribute, SizesAttribute, TypeAttribute, FormEventAttribute { public func accessKey(_ value: Character) -> Link { return mutate(accesskey: value) @@ -997,6 +1065,30 @@ extension Link: GlobalAttributes, ReferenceAttribute, ReferenceLanguageAttribute public func custom(key: String, value: Any) -> Link { return mutate(key: key, value: value) } + + public func on(event: Events.Form, _ value: String) -> Link { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Drag, _ value: String) -> Link { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Link { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Link { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Link { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Link { + return mutate(key: event.rawValue, value: value) + } } extension Link: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/HtmlElements.swift b/Sources/HTMLKit/External/Elements/HtmlElements.swift index f0ca38e6..cec35110 100644 --- a/Sources/HTMLKit/External/Elements/HtmlElements.swift +++ b/Sources/HTMLKit/External/Elements/HtmlElements.swift @@ -37,8 +37,8 @@ public struct Head: ContentNode, HtmlElement { } } -extension Head: GlobalAttributes { - +extension Head: GlobalAttributes, GlobalEventAttributes { + public func accessKey(_ value: Character) -> Head { return mutate(accesskey: value) } @@ -156,6 +156,26 @@ extension Head: GlobalAttributes { public func custom(key: String, value: Any) -> Head { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Head { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Head { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Head { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Head { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Head { + return mutate(key: event.rawValue, value: value) + } } extension Head: AnyContent { @@ -228,43 +248,7 @@ public struct Body: ContentNode, HtmlElement { } } -extension Body: GlobalAttributes, AfterPrintEventAttribute, BeforePrintEventAttribute, BeforeUnloadEventAttribute, HashChangeEventAttribute, LoadEventAttribute, OfflineEventAttribute, OnlineEventAttribute, PageShowEventAttribute, ResizeEventAttribute { - - public func onAfterPrint(_ value: String) -> Body { - return mutate(onafterprint: value) - } - - public func onBeforePrint(_ value: String) -> Body { - return mutate(onbeforeprint: value) - } - - public func onBeforeUnload(_ value: String) -> Body { - return mutate(onbeforeunload: value) - } - - public func onHashChange(_ value: String) -> Body { - return mutate(onhashchange: value) - } - - public func onLoad(_ value: String) -> Body { - return mutate(onload: value) - } - - public func onOffline(_ value: String) -> Body { - return mutate(onoffline: value) - } - - public func onOnline(_ value: String) -> Body { - return mutate(ononline: value) - } - - public func onPageShow(_ value: String) -> Body { - return mutate(onpageshow: value) - } - - public func onResize(_ value: String) -> Body { - return mutate(onresize: value) - } +extension Body: GlobalAttributes, GlobalEventAttributes, WindowEventAttribute { public func accessKey(_ value: Character) -> Body { return mutate(accesskey: value) @@ -383,6 +367,30 @@ extension Body: GlobalAttributes, AfterPrintEventAttribute, BeforePrintEventAttr public func custom(key: String, value: Any) -> Body { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Body { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Body { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Window, _ value: String) -> Body { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Body { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Body { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Body { + return mutate(key: event.rawValue, value: value) + } } extension Body: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/InputElements.swift b/Sources/HTMLKit/External/Elements/InputElements.swift index fe49fd33..008d02d8 100644 --- a/Sources/HTMLKit/External/Elements/InputElements.swift +++ b/Sources/HTMLKit/External/Elements/InputElements.swift @@ -46,7 +46,7 @@ public struct OptionGroup: ContentNode, InputElement { } } -extension OptionGroup: GlobalAttributes, DisabledAttribute, LabelAttribute { +extension OptionGroup: GlobalAttributes, GlobalEventAttributes, DisabledAttribute, LabelAttribute { public func accessKey(_ value: Character) -> OptionGroup { return mutate(accesskey: value) @@ -173,6 +173,26 @@ extension OptionGroup: GlobalAttributes, DisabledAttribute, LabelAttribute { public func custom(key: String, value: Any) -> OptionGroup { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> OptionGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> OptionGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> OptionGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> OptionGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> OptionGroup { + return mutate(key: event.rawValue, value: value) + } } extension OptionGroup: AnyContent { @@ -245,7 +265,7 @@ public struct Option: ContentNode, InputElement { } } -extension Option: GlobalAttributes, DisabledAttribute, LabelAttribute, ValueAttribute, SelectedAttribute { +extension Option: GlobalAttributes, GlobalEventAttributes, DisabledAttribute, LabelAttribute, ValueAttribute, SelectedAttribute { public func accessKey(_ value: Character) -> Option { return mutate(accesskey: value) @@ -384,6 +404,26 @@ extension Option: GlobalAttributes, DisabledAttribute, LabelAttribute, ValueAttr public func custom(key: String, value: Any) -> Option { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Option { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Option { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Option { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Option { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Option { + return mutate(key: event.rawValue, value: value) + } } extension Option: AnyContent { @@ -458,7 +498,7 @@ public struct Legend: ContentNode, InputElement { } } -extension Legend: GlobalAttributes { +extension Legend: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Legend { return mutate(accesskey: value) @@ -577,6 +617,26 @@ extension Legend: GlobalAttributes { public func custom(key: String, value: Any) -> Legend { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Legend { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Legend { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Legend { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Legend { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Legend { + return mutate(key: event.rawValue, value: value) + } } extension Legend: AnyContent { @@ -649,7 +709,7 @@ public struct Summary: ContentNode, InputElement { } } -extension Summary: GlobalAttributes { +extension Summary: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Summary { return mutate(accesskey: value) @@ -768,6 +828,26 @@ extension Summary: GlobalAttributes { public func custom(key: String, value: Any) -> Summary { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Summary { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Summary { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Summary { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Summary { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Summary { + return mutate(key: event.rawValue, value: value) + } } extension Summary: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/ListElements.swift b/Sources/HTMLKit/External/Elements/ListElements.swift index 9841fc85..33f47493 100644 --- a/Sources/HTMLKit/External/Elements/ListElements.swift +++ b/Sources/HTMLKit/External/Elements/ListElements.swift @@ -46,7 +46,7 @@ public struct ListItem: ContentNode, ListElement { } } -extension ListItem: GlobalAttributes, ValueAttribute { +extension ListItem: GlobalAttributes, GlobalEventAttributes, ValueAttribute { public func accessKey(_ value: Character) -> ListItem { return mutate(accesskey: value) @@ -173,6 +173,26 @@ extension ListItem: GlobalAttributes, ValueAttribute { public func custom(key: String, value: Any) -> ListItem { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> ListItem { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> ListItem { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> ListItem { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> ListItem { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> ListItem { + return mutate(key: event.rawValue, value: value) + } } extension ListItem: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/MapElements.swift b/Sources/HTMLKit/External/Elements/MapElements.swift index 14f085b4..d0d1e7df 100644 --- a/Sources/HTMLKit/External/Elements/MapElements.swift +++ b/Sources/HTMLKit/External/Elements/MapElements.swift @@ -37,7 +37,7 @@ public struct Area: ContentNode, MapElement { } } -extension Area: GlobalAttributes, AlternateAttribute, CoordinatesAttribute, ShapeAttribute, ReferenceAttribute, TargetAttribute, DownloadAttribute, PingAttribute, RelationshipAttribute, ReferrerPolicyAttribute { +extension Area: GlobalAttributes, GlobalEventAttributes, AlternateAttribute, CoordinatesAttribute, ShapeAttribute, ReferenceAttribute, TargetAttribute, DownloadAttribute, PingAttribute, RelationshipAttribute, ReferrerPolicyAttribute { public func accessKey(_ value: Character) -> Area { return mutate(accesskey: value) @@ -196,6 +196,26 @@ extension Area: GlobalAttributes, AlternateAttribute, CoordinatesAttribute, Shap public func custom(key: String, value: Any) -> Area { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Area { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Area { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Area { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Area { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Area { + return mutate(key: event.rawValue, value: value) + } } extension Area: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/MediaElements.swift b/Sources/HTMLKit/External/Elements/MediaElements.swift index 315417f1..d154e881 100644 --- a/Sources/HTMLKit/External/Elements/MediaElements.swift +++ b/Sources/HTMLKit/External/Elements/MediaElements.swift @@ -32,7 +32,7 @@ public struct Source: EmptyNode, MediaElement { } } -extension Source: GlobalAttributes, TypeAttribute, SourceAttribute, SizesAttribute, MediaAttribute, WidthAttribute, HeightAttribute { +extension Source: GlobalAttributes, GlobalEventAttributes, TypeAttribute, SourceAttribute, SizesAttribute, MediaAttribute, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> Source { return mutate(accesskey: value) @@ -175,6 +175,26 @@ extension Source: GlobalAttributes, TypeAttribute, SourceAttribute, SizesAttribu public func custom(key: String, value: Any) -> Source { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Source { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Source { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Source { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Source { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Source { + return mutate(key: event.rawValue, value: value) + } } extension Source: AnyContent { @@ -242,7 +262,7 @@ public struct Track: EmptyNode, MediaElement { } } -extension Track: GlobalAttributes, KindAttribute, SourceAttribute, LabelAttribute, DefaultAttribute { +extension Track: GlobalAttributes, GlobalEventAttributes, KindAttribute, SourceAttribute, LabelAttribute, DefaultAttribute { public func accessKey(_ value: Character) -> Track { return mutate(accesskey: value) @@ -382,6 +402,26 @@ extension Track: GlobalAttributes, KindAttribute, SourceAttribute, LabelAttribut public func custom(key: String, value: Any) -> Track { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Track { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Track { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Track { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Track { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Track { + return mutate(key: event.rawValue, value: value) + } } extension Track: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/ObjectElements.swift b/Sources/HTMLKit/External/Elements/ObjectElements.swift index 7d75f51f..d5617c32 100644 --- a/Sources/HTMLKit/External/Elements/ObjectElements.swift +++ b/Sources/HTMLKit/External/Elements/ObjectElements.swift @@ -32,7 +32,7 @@ public struct Parameter: EmptyNode, ObjectElement { } } -extension Parameter: GlobalAttributes, NameAttribute, ValueAttribute { +extension Parameter: GlobalAttributes, GlobalEventAttributes, NameAttribute, ValueAttribute { public func accessKey(_ value: Character) -> Parameter { return mutate(accesskey: value) @@ -167,6 +167,26 @@ extension Parameter: GlobalAttributes, NameAttribute, ValueAttribute { public func custom(key: String, value: Any) -> Parameter { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Parameter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Parameter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Parameter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Parameter { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Parameter { + return mutate(key: event.rawValue, value: value) + } } extension Parameter: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/RubyElements.swift b/Sources/HTMLKit/External/Elements/RubyElements.swift index e0e0c5ac..35a1f8bd 100644 --- a/Sources/HTMLKit/External/Elements/RubyElements.swift +++ b/Sources/HTMLKit/External/Elements/RubyElements.swift @@ -55,7 +55,7 @@ public struct RubyText: ContentNode, RubyElement { } } -extension RubyText: GlobalAttributes { +extension RubyText: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> RubyText { return mutate(accesskey: value) @@ -174,6 +174,26 @@ extension RubyText: GlobalAttributes { public func custom(key: String, value: Any) -> RubyText { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> RubyText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> RubyText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> RubyText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> RubyText { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> RubyText { + return mutate(key: event.rawValue, value: value) + } } extension RubyText: AnyContent { @@ -246,7 +266,7 @@ public struct RubyPronunciation: ContentNode, RubyElement { } } -extension RubyPronunciation: GlobalAttributes { +extension RubyPronunciation: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> RubyPronunciation { return mutate(accesskey: value) @@ -365,6 +385,26 @@ extension RubyPronunciation: GlobalAttributes { public func custom(key: String, value: Any) -> RubyPronunciation { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> RubyPronunciation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> RubyPronunciation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> RubyPronunciation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> RubyPronunciation { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> RubyPronunciation { + return mutate(key: event.rawValue, value: value) + } } extension RubyPronunciation: AnyContent { diff --git a/Sources/HTMLKit/External/Elements/TableElements.swift b/Sources/HTMLKit/External/Elements/TableElements.swift index fa34e904..7f94feee 100644 --- a/Sources/HTMLKit/External/Elements/TableElements.swift +++ b/Sources/HTMLKit/External/Elements/TableElements.swift @@ -109,7 +109,7 @@ public struct Caption: ContentNode, TableElement { } } -extension Caption: GlobalAttributes { +extension Caption: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> Caption { return mutate(accesskey: value) @@ -228,6 +228,26 @@ extension Caption: GlobalAttributes { public func custom(key: String, value: Any) -> Caption { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Caption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Caption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Caption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Caption { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Caption { + return mutate(key: event.rawValue, value: value) + } } extension Caption: AnyContent { @@ -300,7 +320,7 @@ public struct ColumnGroup: ContentNode, TableElement { } } -extension ColumnGroup: GlobalAttributes, SpanAttribute { +extension ColumnGroup: GlobalAttributes, GlobalEventAttributes, SpanAttribute { public func accessKey(_ value: Character) -> ColumnGroup { return mutate(accesskey: value) @@ -423,6 +443,26 @@ extension ColumnGroup: GlobalAttributes, SpanAttribute { public func custom(key: String, value: Any) -> ColumnGroup { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> ColumnGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> ColumnGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> ColumnGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> ColumnGroup { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> ColumnGroup { + return mutate(key: event.rawValue, value: value) + } } extension ColumnGroup: AnyContent { @@ -495,7 +535,7 @@ public struct Column: ContentNode, TableElement { } } -extension Column: GlobalAttributes, SpanAttribute { +extension Column: GlobalAttributes, GlobalEventAttributes, SpanAttribute { public func accessKey(_ value: Character) -> Column { return mutate(accesskey: value) @@ -618,6 +658,26 @@ extension Column: GlobalAttributes, SpanAttribute { public func custom(key: String, value: Any) -> Column { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> Column { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> Column { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> Column { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> Column { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> Column { + return mutate(key: event.rawValue, value: value) + } } extension Column: AnyContent { @@ -690,7 +750,7 @@ public struct TableBody: ContentNode, TableElement { } } -extension TableBody: GlobalAttributes, WidthAttribute, HeightAttribute { +extension TableBody: GlobalAttributes, GlobalEventAttributes, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> TableBody { return mutate(accesskey: value) @@ -817,6 +877,26 @@ extension TableBody: GlobalAttributes, WidthAttribute, HeightAttribute { public func custom(key: String, value: Any) -> TableBody { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TableBody { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TableBody { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TableBody { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TableBody { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TableBody { + return mutate(key: event.rawValue, value: value) + } } extension TableBody: AnyContent { @@ -889,7 +969,7 @@ public struct TableHead: ContentNode, TableElement { } } -extension TableHead: GlobalAttributes, WidthAttribute, HeightAttribute { +extension TableHead: GlobalAttributes, GlobalEventAttributes, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> TableHead { return mutate(accesskey: value) @@ -1016,6 +1096,26 @@ extension TableHead: GlobalAttributes, WidthAttribute, HeightAttribute { public func custom(key: String, value: Any) -> TableHead { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TableHead { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TableHead { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TableHead { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TableHead { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TableHead { + return mutate(key: event.rawValue, value: value) + } } extension TableHead: AnyContent { @@ -1088,7 +1188,7 @@ public struct TableFoot: ContentNode, TableElement { } } -extension TableFoot: GlobalAttributes { +extension TableFoot: GlobalAttributes, GlobalEventAttributes { public func accessKey(_ value: Character) -> TableFoot { return mutate(accesskey: value) @@ -1207,6 +1307,26 @@ extension TableFoot: GlobalAttributes { public func custom(key: String, value: Any) -> TableFoot { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TableFoot { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TableFoot { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TableFoot { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TableFoot { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TableFoot { + return mutate(key: event.rawValue, value: value) + } } extension TableFoot: AnyContent { @@ -1279,7 +1399,7 @@ public struct TableRow: ContentNode, TableElement { } } -extension TableRow: GlobalAttributes, WidthAttribute, HeightAttribute { +extension TableRow: GlobalAttributes, GlobalEventAttributes, WidthAttribute, HeightAttribute { public func accessKey(_ value: Character) -> TableRow { return mutate(accesskey: value) @@ -1406,6 +1526,26 @@ extension TableRow: GlobalAttributes, WidthAttribute, HeightAttribute { public func custom(key: String, value: Any) -> TableRow { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> TableRow { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> TableRow { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> TableRow { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> TableRow { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> TableRow { + return mutate(key: event.rawValue, value: value) + } } extension TableRow: AnyContent { @@ -1478,7 +1618,7 @@ public struct DataCell: ContentNode, TableElement { } } -extension DataCell: GlobalAttributes, ColumnSpanAttribute, RowSpanAttribute, HeaderAttribute { +extension DataCell: GlobalAttributes, GlobalEventAttributes, ColumnSpanAttribute, RowSpanAttribute, HeaderAttribute { public func accessKey(_ value: Character) -> DataCell { return mutate(accesskey: value) @@ -1609,6 +1749,26 @@ extension DataCell: GlobalAttributes, ColumnSpanAttribute, RowSpanAttribute, Hea public func custom(key: String, value: Any) -> DataCell { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> DataCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> DataCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> DataCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> DataCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> DataCell { + return mutate(key: event.rawValue, value: value) + } } extension DataCell: AnyContent { @@ -1681,7 +1841,7 @@ public struct HeaderCell: ContentNode, TableElement { } } -extension HeaderCell: GlobalAttributes, ColumnSpanAttribute, RowSpanAttribute, HeaderAttribute, ScopeAttribute { +extension HeaderCell: GlobalAttributes, GlobalEventAttributes, ColumnSpanAttribute, RowSpanAttribute, HeaderAttribute, ScopeAttribute { public func accessKey(_ value: Character) -> HeaderCell { return mutate(accesskey: value) @@ -1816,6 +1976,26 @@ extension HeaderCell: GlobalAttributes, ColumnSpanAttribute, RowSpanAttribute, H public func custom(key: String, value: Any) -> HeaderCell { return mutate(key: key, value: value) } + + public func on(event: Events.Drag, _ value: String) -> HeaderCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Clipboard, _ value: String) -> HeaderCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Keyboard, _ value: String) -> HeaderCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Mouse, _ value: String) -> HeaderCell { + return mutate(key: event.rawValue, value: value) + } + + public func on(event: Events.Wheel, _ value: String) -> HeaderCell { + return mutate(key: event.rawValue, value: value) + } } extension HeaderCell: AnyContent { diff --git a/Sources/HTMLKit/External/Events.swift b/Sources/HTMLKit/External/Events.swift new file mode 100644 index 00000000..8f722624 --- /dev/null +++ b/Sources/HTMLKit/External/Events.swift @@ -0,0 +1,330 @@ +/* + Abstract: + The file contains event-types. + + Note: + If you about to add something to the file, stick to the official documentation to keep the code consistent. + */ + +/// A namespace for several types of events. +public enum Events { + + /// A event for the window element. + public enum Window: String { + + /// Occurs, when the document has started printing or the print preview has been closed. + case afterprint = "onafterprint" + + /// Occurs, when the document is about to be printed or the print preview is open. + case beforeprint = "onbeforeprint" + + /// Occurs, when + case beforeunload = "onbeforeunload" + + /// Occurs, when the fragment identifier of the url is being changed. + case hashchange = "onhashchange" + + /// Occurs, when the language has been changed. + case languagechange = "onlanguagechange" + + /// Occurs, when the window element is recieving a message. + case message = "onmessage" + + /// Occurs, when the recieving message cannot be deserialized. + case messageerror = "onmessageerror" + + /// Occurs, when + case offline = "onoffline" + + /// Occurs, when + case online = "ononline" + + /// Occurs, when a page has lost focus. + case pagehide = "onpagehide" + + /// Occurs, when a page is focused. + case pageshow = "onpageshow" + + /// Occurs, when + case popstate = "onpopstate" + + /// Occurs, when + case rejectionhandled = "onrejectionhandled" + + /// Occurs, when the storage context has been changed. + case storage = "onstorage" + + /// Occurs, when + case unhandledrejection = "onunhandledrejection" + + /// Occurs, when + case unload = "onunload" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event + public enum Focus: String { + + /// Occurs, when a element has lost focus. + case blur = "onblur" + + /// Occurs, when a element is being focused. + case focus = "onfocus" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for a pointing device. + public enum Pointer: String { + + /// Occurs, when + case pointercancel = "onpointercancel" + + /// Occurs, when the pointing device is pressed. + case pointerdown = "onpointerdown" + + /// Occurs, when + case pointerenter = "onpointerenter" + + /// Occurs, when + case pointerleave = "onpointerleave" + + /// Occurs, when + case pointermove = "onpointermove" + + /// Occurs, when + case pointerout = "onpointerout" + + /// Occurs, when + case pointerover = "onpointerover" + + /// Occurs, when the pointing device is not pressed anymore. + case pointerup = "onpointerup" + + /// Occurs, when + case gotpointercapture = "ongotpointercapture" + + /// Occurs, when + case lostpointercapture = "onlostpointercapture" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for a mouse device. + public enum Mouse: String { + + /// Occurs, when a element is being clicked. + case click = "onclick" + + /// Occurs, when the right mouse button is pressed. + case contextmenu = "oncontextmenu" + + /// Occurs, when a element is being clicked twice in time. + case doubleclick = "ondblclick" + + /// Occurs, when a mouse button is pressed and not yet released. + case mousedown = "onmousedown" + + /// Occurs, when + case mouseenter = "onmouseenter" + + /// Occurs, when + case mouseleave = "onmouseleave" + + /// Occurs, when the mouse moves. + case mousemove = "onmousemove" + + /// Occurs, when + case mouseout = "onmouseout" + + /// Occurs, when the mouse pointer is over a particular element. + case mouseover = "onmouseover" + + /// Occurs, when a mouse button is released. + case mouseup = "onmouseup" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for a mouse device. + public enum Wheel: String { + + /// Occurs, when the mouse wheel rotates. + case wheel = "onwheel" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event + public enum Input: String { + + /// Occurs, when the value of the element is about to be modified. + case beforeinput = "onbeforeinput" + + /// Occurs, when the value of the element has been modified. + case input = "oninput" + + /// Occurs, when the value within the element has been selected. + case select = "onselect" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for a keyboard device. + public enum Keyboard: String { + + /// Occurs, when a key is pressed and not yet released. + case keydown = "onkeydown" + + /// Occurs, when a key releases. + case keyup = "onkeyup" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event + public enum Drag: String { + + /// Occurs, when a element is being dragged. + case drag = "ondrag" + + /// Occurs, when a drag operation is being ended. + case dragend = "ondragend" + + /// Occurs, when a dragged element is entering a valid target. + case dragenter = "ondragenter" + + /// Occurs, when a dragged element is leaving a valid target. + case dragleave = "ondragleave" + + /// Occurs, when a a dragged element is over a valid target. + case dragover = "ondragover" + + /// Occurs, when a drag operation starts. + case dragstart = "ondragstart" + + /// Occurs, when a dragged element has been dropped on a valid target. + case drop = "ondrop" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event + public enum Clipboard: String { + + /// Occurs, when a copy action is initated. + case copy = "oncopy" + + /// Occurs, when a cut action is initated. + case cut = "oncut" + + /// Occurs, when a paste action is initated. + case paste = "onpaste" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event + public enum Selection: String { + + /// Occurs, when + case selectionchange = "onselectionchange" + + /// Occurs, when + case selectstart = "onselectstart" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for the audio and video element. + public enum Media: String { + + /// Occurs, when the ressource cannot be loaded. + case abort = "onabort" + + /// Occurs, when the playback can be started, but the loading operation is still processing. + case canplay = "oncanplay" + + /// Occurs, when the playback can be started and the loading operation is done. + case canplaythrough = "oncanplaythrough" + + /// Occurs, when the duration is being updated. + case durationchange = "ondurationchange" + + /// Occurs, when + case emptied = "onemptied" + + /// Occurs, when the end of the media is reached. + case ended = "onended" + + /// Occurs, when the playback starts. + case play = "onplay" + + /// Occurs, when the playback has resumed. + case playing = "onplaying" + + /// Occurs, when the playback has paused. + case pause = "onpause" + + /// Occurs, when the playback rate has changed. + case ratechange = "onratechange" + + /// Occurs, when a seek operation has been completed. + case seeked = "onseeked" + + /// Occurs, when a seek operation starts. + case seeking = "onseeking" + + /// Occurs, when the loading operation is unexpectedly not forthcoming. + case stalled = "onstalled" + + /// Occurs, when the loading operation has been suspended. + case suspend = "onsuspend" + + /// Occurs, when the current time has been updated. + case timeupdate = "ontimeupdate" + + /// Occurs, when the volume has changed. + case volumenchange = "onvolumechange" + + /// Occurs, when the playback has stopped, cause of lack of data. + case waiting = "onwaiting" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for the form element. + public enum Form: String { + + /// Occurs, when the reset button within the form element is clicked. + case reset = "onreset" + + /// Occurs, when the form is submitted. + case submit = "onsubmit" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } + + /// A event for the dialog element. + public enum Detail: String { + + /// Occurs, when the detail element is toggled (open/closed). + case toggle = "ontoggle" + + /// Occurs for various targets and different kinds of reasons. + case error = "onerror" + } +} diff --git a/Tests/HTMLKitTests/AttributesTests.swift b/Tests/HTMLKitTests/AttributesTests.swift index f29432e5..9a892080 100644 --- a/Tests/HTMLKitTests/AttributesTests.swift +++ b/Tests/HTMLKitTests/AttributesTests.swift @@ -9,7 +9,7 @@ final class AttributesTests: XCTestCase { @ContentBuilder var body: AnyContent } - typealias AllAttributes = AccessKeyAttribute & AcceptAttribute & ActionAttribute & AlternateAttribute & AsynchronouslyAttribute & AutocapitalizeAttribute & AutocompleteAttribute & AutofocusAttribute & AutoplayAttribute & CharsetAttribute & CheckedAttribute & CiteAttribute & ClassAttribute & ColumnsAttribute & ColumnSpanAttribute & ContentAttribute & EditAttribute & ControlsAttribute & CoordinatesAttribute & DataAttribute & DateTimeAttribute & DefaultAttribute & DeferAttribute & DirectionAttribute & DisabledAttribute & DownloadAttribute & DragAttribute & EncodingAttribute & EnterKeyHintAttribute & ForAttribute & FormAttribute & FormActionAttribute & EquivalentAttribute & HeaderAttribute & HeightAttribute & HiddenAttribute & HighAttribute & ReferenceAttribute & ReferenceLanguageAttribute & IdentifierAttribute & IsMapAttribute & InputModeAttribute & IsAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & KindAttribute & LabelAttribute & LanguageAttribute & ListAttribute & LoopAttribute & LowAttribute & MaximumValueAttribute & MaximumLengthAttribute & MediaAttribute & MethodAttribute & MinimumValueAttribute & MinimumLengthAttribute & MultipleAttribute & MutedAttribute & NameAttribute & NonceAttribute & NoValidateAttribute & OpenAttribute & OptimumAttribute & PatternAttribute & PartAttribute & PingAttribute & PlaceholderAttribute & PosterAttribute & PreloadAttribute & ReadyOnlyAttribute & ReferrerPolicyAttribute & RelationshipAttribute & RequiredAttribute & ReversedAttribute & RoleAttribute & RowsAttribute & RowSpanAttribute & SandboxAttribute & ScopeAttribute & ShapeAttribute & SizeAttribute & SizesAttribute & SlotAttribute & SpanAttribute & SpellCheckAttribute & SourceAttribute & StartAttribute & StepAttribute & StyleAttribute & TabulatorAttribute & TargetAttribute & TitleAttribute & TranslateAttribute & TypeAttribute & ValueAttribute & WidthAttribute & WrapAttribute & PropertyAttribute & SelectedAttribute + typealias AllAttributes = AccessKeyAttribute & AcceptAttribute & ActionAttribute & AlternateAttribute & AsynchronouslyAttribute & AutocapitalizeAttribute & AutocompleteAttribute & AutofocusAttribute & AutoplayAttribute & CharsetAttribute & CheckedAttribute & CiteAttribute & ClassAttribute & ColumnsAttribute & ColumnSpanAttribute & ContentAttribute & EditAttribute & ControlsAttribute & CoordinatesAttribute & DataAttribute & DateTimeAttribute & DefaultAttribute & DeferAttribute & DirectionAttribute & DisabledAttribute & DownloadAttribute & DragAttribute & EncodingAttribute & EnterKeyHintAttribute & ForAttribute & FormAttribute & FormActionAttribute & EquivalentAttribute & HeaderAttribute & HeightAttribute & HiddenAttribute & HighAttribute & ReferenceAttribute & ReferenceLanguageAttribute & IdentifierAttribute & IsMapAttribute & InputModeAttribute & IsAttribute & ItemIdAttribute & ItemPropertyAttribute & ItemReferenceAttribute & ItemScopeAttribute & ItemTypeAttribute & KindAttribute & LabelAttribute & LanguageAttribute & ListAttribute & LoopAttribute & LowAttribute & MaximumValueAttribute & MaximumLengthAttribute & MediaAttribute & MethodAttribute & MinimumValueAttribute & MinimumLengthAttribute & MultipleAttribute & MutedAttribute & NameAttribute & NonceAttribute & NoValidateAttribute & OpenAttribute & OptimumAttribute & PatternAttribute & PartAttribute & PingAttribute & PlaceholderAttribute & PosterAttribute & PreloadAttribute & ReadyOnlyAttribute & ReferrerPolicyAttribute & RelationshipAttribute & RequiredAttribute & ReversedAttribute & RoleAttribute & RowsAttribute & RowSpanAttribute & SandboxAttribute & ScopeAttribute & ShapeAttribute & SizeAttribute & SizesAttribute & SlotAttribute & SpanAttribute & SpellCheckAttribute & SourceAttribute & StartAttribute & StepAttribute & StyleAttribute & TabulatorAttribute & TargetAttribute & TitleAttribute & TranslateAttribute & TypeAttribute & ValueAttribute & WidthAttribute & WrapAttribute & PropertyAttribute & SelectedAttribute & WindowEventAttribute & FocusEventAttribute & PointerEventAttribute & MouseEventAttribute & WheelEventAttribute & InputEventAttribute & KeyboardEventAttribute & DragEventAttribute & ClipboardEventAttribute & SelectionEventAttribute & MediaEventAttribute & FormEventAttribute & DetailEventAttribute struct Tag: ContentNode, GlobalElement, AllAttributes { @@ -468,6 +468,58 @@ final class AttributesTests: XCTestCase { return self.mutate(key: key, value: value) } + func on(event: Events.Window, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Focus, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Pointer, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Mouse, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Wheel, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Input, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Keyboard, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Drag, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Clipboard, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Selection, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Media, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Form, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + + func on(event: Events.Detail, _ value: String) -> Tag { + return self.mutate(key: event.rawValue, value: value) + } + func prerender(_ formula: Renderer.Formula) throws { try self.build(formula) } @@ -2059,6 +2111,227 @@ final class AttributesTests: XCTestCase { """ ) } + + func testWindowEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .afterprint, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testFocusEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .focus, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testPointerEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .pointerup, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testMouseEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .mouseup, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testWheelEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .wheel, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testInputEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .input, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testKeyboardEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .keyup, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testDragEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .drag, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testClipboardEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .paste, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testSelectionEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .selectstart, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testMediaEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .play, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testFormEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .submit, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } + + func testDetailEventAttribute() throws { + + let view = TestPage { + Tag { + } + .on(event: .toggle, "script") + } + + try renderer.add(view: view) + + XCTAssertEqual(try renderer.render(raw: TestPage.self), + """ + + """ + ) + } } extension AttributesTests { @@ -2156,6 +2429,19 @@ extension AttributesTests { ("testTargetAttribute", testTargetAttribute), ("testTypeAttribute", testTypeAttribute), ("testSelectedAttribute", testSelectedAttribute), - ("testCustomAttribute", testCustomAttribute) + ("testCustomAttribute", testCustomAttribute), + ("testWindowEventAttribute", testWindowEventAttribute), + ("testFocusEventAttribute", testFocusEventAttribute), + ("testPointerEventAttribute", testPointerEventAttribute), + ("testMouseEventAttribute", testMouseEventAttribute), + ("testWheelEventAttribute", testWheelEventAttribute), + ("testInputEventAttribute", testInputEventAttribute), + ("testKeyboardEventAttribute", testKeyboardEventAttribute), + ("testDragEventAttribute", testDragEventAttribute), + ("testClipboardEventAttribute", testClipboardEventAttribute), + ("testSelectionEventAttribute", testSelectionEventAttribute), + ("testMediaEventAttribute", testMediaEventAttribute), + ("testFormEventAttribute", testFormEventAttribute), + ("testDetailEventAttribute", testDetailEventAttribute) ] }