-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the "_" Hyperscript attribute. (#13)
* Added the '_' attribute for Hyperscript support. * fix * fix * fix * Update Readme. * renamed to `hyperscript` --------- Co-authored-by: Simon Leeb <[email protected]>
- Loading branch information
1 parent
0a34f2f
commit c0df782
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Sources/ElementaryHyperscript/HTMLAttribute+Hyperscript.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Elementary | ||
|
||
public extension HTMLAttribute where Tag: HTMLTrait.Attributes.Global { | ||
static func hyperscript(_ script: String) -> Self { | ||
.init(name: "_", value: script) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Tests/ElementaryHyperscriptTest/ElementaryHyperscriptTest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Elementary | ||
import ElementaryHyperscript | ||
import TestUtilities | ||
import XCTest | ||
|
||
final class elementary_hyperscriptTests: XCTestCase { | ||
func testScript() { | ||
HTMLAttributeAssertEqual(.hyperscript("on click send hello to <form />"), "_", "on click send hello to <form />") | ||
} | ||
} |