-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of #27.
- Loading branch information
Showing
5 changed files
with
42 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extension View { | ||
/// Sets the element's unique identifier (ID).. | ||
/// | ||
/// - Parameter identifier: There are no other restrictions on what form an ID can take; in particular, | ||
/// IDs can consist of just digits, start with a digit, start with an | ||
/// underscore, consist of just punctuation, etc. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public func id(_ identifier: String) -> some View { | ||
return modifier(AttributeModifier(.id, value: identifier)) | ||
} | ||
} |
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,22 @@ | ||
import Testing | ||
|
||
import Slipstream | ||
|
||
private struct IDView: View { | ||
var body: some View { | ||
HTML { | ||
Text("Bonjour!") | ||
} | ||
.id("root") | ||
} | ||
} | ||
|
||
struct IDTests { | ||
@Test func french() throws { | ||
try #expect(renderHTML(IDView()) == """ | ||
<html id="root"> | ||
Bonjour! | ||
</html> | ||
""") | ||
} | ||
} |
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
File renamed without changes.