From 9c43f07a72b88c76b347b565277b97737a1d3ab5 Mon Sep 17 00:00:00 2001 From: Mattes Mohr Date: Sun, 2 Jul 2023 11:14:08 +0200 Subject: [PATCH 1/3] Start to add conditional attributes --- .../Attributes/BasicAttributes.swift | 12 + .../Abstraction/Elements/BasicElements.swift | 9 + .../Abstraction/Elements/BodyElements.swift | 692 +++++++++++++++++- .../Elements/DefinitionElements.swift | 18 + .../Abstraction/Elements/FigureElements.swift | 9 + .../Abstraction/Elements/FormElements.swift | 153 ++++ .../Abstraction/Elements/HeadElements.swift | 45 ++ .../Abstraction/Elements/HtmlElements.swift | 18 + .../Abstraction/Elements/InputElements.swift | 54 ++ .../Abstraction/Elements/ListElements.swift | 9 + .../Abstraction/Elements/MapElements.swift | 9 + .../Abstraction/Elements/MediaElements.swift | 18 + .../Abstraction/Elements/ObjectElements.swift | 9 + .../Abstraction/Elements/RubyElements.swift | 18 + .../Abstraction/Elements/TableElements.swift | 81 ++ Tests/HTMLKitTests/AttributesTests.swift | 660 ++++++----------- 16 files changed, 1387 insertions(+), 427 deletions(-) diff --git a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift index 0d2cfbb7..1e352db8 100644 --- a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift +++ b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift @@ -223,6 +223,8 @@ public protocol AutoplayAttribute: Attribute { /// /// ``` func autoplay() -> Self + + func autoplay(_ condition: Bool) -> Self } extension AutoplayAttribute where Self: ContentNode { @@ -273,6 +275,8 @@ public protocol CheckedAttribute: Attribute { /// /// ``` func checked() -> Self + + func checked(_ condition: Bool) -> Self } extension CheckedAttribute where Self: ContentNode { @@ -625,6 +629,8 @@ public protocol DisabledAttribute: Attribute { /// /// ``` func disabled() -> Self + + func disabled(_ condition: Bool) -> Self } extension DisabledAttribute where Self: ContentNode { @@ -914,6 +920,8 @@ public protocol HiddenAttribute: Attribute { ///