Skip to content

Commit

Permalink
[generics] Removed the Root generic as this is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsMoll committed Dec 29, 2019
1 parent 7cf9c32 commit 487020a
Show file tree
Hide file tree
Showing 13 changed files with 518 additions and 220 deletions.
35 changes: 20 additions & 15 deletions Sources/HTMLKit/AttributeNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public protocol GlobalAttributes {
///
/// - Parameter value: The value of the attribute
/// - Returns: An attribute node
func direction<T>(_ value: TemplateValue<T, HTMLTextDirection>) -> Self
func direction(_ value: TemplateValue<HTMLTextDirection>) -> Self

/// Specifies that an element is not yet, or is no longer, relevant
///
Expand All @@ -70,7 +70,7 @@ public protocol GlobalAttributes {
///
/// - Parameter value: The value of the attribute
/// - Returns: An attribute node
func lang<T>(_ value: TemplateValue<T, String>) -> Self
func lang(_ value: TemplateValue<String>) -> Self

/// Specifies whether the element is to have its spelling and grammar checked or not
func isSpellchecked(_ value: Conditionable) -> Self
Expand All @@ -79,7 +79,7 @@ public protocol GlobalAttributes {
///
/// - Parameter value: The value of the attribute
/// - Returns: An attribute node
func tabIndex<T>(_ value: TemplateValue<T, Int>) -> Self
func tabIndex(_ value: TemplateValue<Int>) -> Self

/// Specifies extra information about an element
///
Expand Down Expand Up @@ -128,12 +128,12 @@ extension GlobalAttributes where Self: AttributeNode {
add(HTMLAttribute(attribute: "contenteditable", value: value))
}

public func direction<T>(_ value: TemplateValue<T, HTMLTextDirection>) -> Self {
public func direction(_ value: TemplateValue<HTMLTextDirection>) -> Self {
add(HTMLAttribute(attribute: "dir", value: value))
}

public func direction(_ value: HTMLTextDirection) -> Self {
direction(TemplateValue<Void, HTMLTextDirection>.constant(value))
direction(.constant(value))
}

public func isHidden(_ value: Conditionable) -> Self {
Expand All @@ -144,15 +144,15 @@ extension GlobalAttributes where Self: AttributeNode {
add(HTMLAttribute(attribute: "id", value: value))
}

public func lang<T>(_ value: TemplateValue<T, String>) -> Self {
public func lang(_ value: TemplateValue<String>) -> Self {
add(HTMLAttribute(attribute: "lang", value: value))
}

public func isSpellchecked(_ value: Conditionable) -> Self {
add(HTMLAttribute(attribute: "spellcheck", value: value))
}

public func tabIndex<T>(_ value: TemplateValue<T, Int>) -> Self {
public func tabIndex(_ value: TemplateValue<Int>) -> Self {
add(HTMLAttribute(attribute: "tabindex", value: value))
}

Expand All @@ -178,17 +178,12 @@ public protocol TypableAttribute {
///
/// - Parameter value: The value of the attribute
/// - Returns: An attribute node
func type<T>(_ value: TemplateValue<T, String>) -> Self
func type(_ value: String) -> Self
func type(_ value: TemplateValue<String>) -> Self
}

extension TypableAttribute where Self: AttributeNode {
public func type<T>(_ value: TemplateValue<T, String>) -> Self {
add(HTMLAttribute(attribute: "type", value: value))
}

public func type(_ value: String) -> Self {
self.type(RootValue<String>.constant(value))
public func type(_ value: TemplateValue<String>) -> Self {
return add(HTMLAttribute(attribute: "type", value: value))
}
}

Expand Down Expand Up @@ -333,12 +328,22 @@ public protocol NameableAttribute {
/// - Parameter value: The value of the attribute
/// - Returns: An attribute node
func name(_ value: NameType) -> Self

/// Specifies the name of the element
///
/// - Parameter value: The value of the attribute
/// - Returns: An attribute node
func name(_ value: TemplateValue<String>) -> Self
}

extension NameableAttribute where Self: AttributeNode {
public func name(_ value: NameType) -> Self {
add(HTMLAttribute(attribute: "name", value: value.rawValue))
}

public func name(_ value: TemplateValue<String>) -> Self {
add(HTMLAttribute(attribute: "name", value: value))
}
}

extension String: RawRepresentable {
Expand Down
Loading

0 comments on commit 487020a

Please sign in to comment.