-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rdom): add DOM comment support (#367), other refactorings
- add $comment(), isComment() - add Component.$comment() syntax sugar - add comment check/branch in $tree() - update args for $addChild(), $remove(), $moveTo() - update $text(), $html() to support SVG elements - add doc strings
- Loading branch information
1 parent
fe952d5
commit 3fd5f8e
Showing
3 changed files
with
195 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
import { implementsFunction } from "@thi.ng/checks/implements-function"; | ||
import { COMMENT } from "@thi.ng/hiccup/api"; | ||
import type { IComponent } from "./api.js"; | ||
|
||
/** | ||
* Returns true if given hiccup component describes a comment node. I.e. is of | ||
* the form `[COMMENT, "foo"...]`. | ||
* | ||
* @remarks | ||
* See thi.ng/hiccup docs for reference: | ||
* - https://docs.thi.ng/umbrella/hiccup/functions/serialize.html | ||
* | ||
* @param tree | ||
*/ | ||
export const isComment = (tree: any[]) => tree[0] === COMMENT; | ||
|
||
/** | ||
* Returns true, if given value has a {@link IComponent.mount} function. | ||
* | ||
* @param x | ||
*/ | ||
export const isComponent = (x: any): x is IComponent<any> => | ||
implementsFunction(x, "mount"); |
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