From 228a2e09ea6cc28f74f8d43081deef76a522f1f0 Mon Sep 17 00:00:00 2001 From: Mattes Mohr Date: Mon, 10 Jul 2023 18:21:40 +0200 Subject: [PATCH] Upgrade the package (#136) * Start to add conditional attributes * Revise the rendering of attributes The renderer should also take an environment value as attribute value into account. * Add support for concating environment values with string and vice versa --- .../Attributes/BasicAttributes.swift | 22 + .../Abstraction/Elements/BasicElements.swift | 9 + .../Abstraction/Elements/BodyElements.swift | 716 +++++++++++++++++- .../Elements/DefinitionElements.swift | 18 + .../Abstraction/Elements/FigureElements.swift | 9 + .../Abstraction/Elements/FormElements.swift | 157 ++++ .../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 | 26 + .../Abstraction/Elements/ObjectElements.swift | 9 + .../Abstraction/Elements/RubyElements.swift | 18 + .../Abstraction/Elements/TableElements.swift | 81 ++ .../Environment/EnvironmentValue.swift | 7 + .../Extensions/Datatypes+Content.swift | 7 +- .../Framework/Primitives/Nodes/Nodes.swift | 53 -- .../Framework/Rendering/Renderer.swift | 66 +- Tests/HTMLKitTests/AttributesTests.swift | 664 ++++++---------- Tests/HTMLKitTests/EnvironmentTests.swift | 14 +- 21 files changed, 1515 insertions(+), 496 deletions(-) diff --git a/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift b/Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift index 0d2cfbb7..87310709 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 { ///