Skip to content

Commit

Permalink
Minor fix (#64)
Browse files Browse the repository at this point in the history
* Add the selected attribute

* Fix the conversion of the image attribute

* Add a rendering test for the custom attribute

* Add scopes to the elements

* Add more building options to the content builder

* Work on the performance tests

* Fix minor issue
  • Loading branch information
mattesmohr authored Jan 26, 2022
1 parent 50df5f1 commit df4c0e4
Show file tree
Hide file tree
Showing 11 changed files with 460 additions and 300 deletions.
31 changes: 31 additions & 0 deletions Sources/HTMLKit/External/Attributes/BasicAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4478,3 +4478,34 @@ extension CustomAttribute where Self: EmptyNode {
return .init(attributes: update(key: key, value: value, on: &attributes))
}
}

/// ## Description
/// The protocol provides the element with the selected handler.
///
/// ## References
/// https://html.spec.whatwg.org/#attr-option-selected
///
public protocol SelectedAttribute: AnyAttribute {

/// The func adds
///
///
func selected() -> Self
}

extension SelectedAttribute {

internal var key: String { "selected" }
}

extension SelectedAttribute where Self: ContentNode {

internal func mutate(selected value: String) -> Self {

guard var attributes = self.attributes else {
return .init(attributes: set(key: key, value: value), content: content)
}

return .init(attributes: update(key: key, value: value, on: &attributes), content: content)
}
}
Loading

0 comments on commit df4c0e4

Please sign in to comment.