-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
/** | ||
* Represents a node in the JsonML tree. Can be a string or an element. | ||
*/ | ||
export type JsonMlNode = string | JsonMlElement; | ||
export type JsonMlElement = [tag: string | number, attrs: null | Record<string, unknown>, ...children: JsonMlNode[]]; | ||
|
||
/** | ||
* Represents an element in the JsonML tree. Lke an HTML element. | ||
*/ | ||
export type JsonMlElement = [ | ||
/** | ||
* Tag name of the element. An empty string `''` tag represents a *fragment* - | ||
* a list of nodes. Similar to a `DocumentFragment` in the DOM, or | ||
* `React.Fragment` `<>` in React. | ||
* | ||
* When converting to HTML, an empty string tag is not rendered and numeric | ||
* tags are converted to strings. | ||
*/ | ||
tag: '' | string | number, | ||
|
||
/** | ||
* Attributes of the element. `null` if there are no attributes. Attribute | ||
* object values are converted to strings when formatting to HTML. | ||
*/ | ||
attrs: null | Record<string, unknown>, | ||
|
||
/** | ||
* Child nodes of the element. Can be a mix of strings and elements. | ||
*/ | ||
...children: JsonMlNode[], | ||
]; |