Skip to content

Commit

Permalink
feat(hdom-canvas): add .toHiccup() interface support
Browse files Browse the repository at this point in the history
- add `.toHiccup()` type check in `normalizeTree()` and call w/
  user context
  • Loading branch information
postspectacular committed Sep 14, 2018
1 parent 54ba0ce commit 8ecdd13
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/hdom-canvas/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IObjectOf } from "@thi.ng/api/api";
import { implementsFunction } from "@thi.ng/checks/implements-function";
import { isArray } from "@thi.ng/checks/is-array";
import { isArrayLike } from "@thi.ng/checks/is-arraylike";
import { isFunction } from "@thi.ng/checks/is-function";
Expand Down Expand Up @@ -126,6 +127,10 @@ export const normalizeTree = (opts: Partial<HDOMOpts>, tree: any) => {
}
} else if (isFunction(tree)) {
return normalizeTree(opts, tree(opts.ctx));
} else if (implementsFunction(tree, "toHiccup")) {
return normalizeTree(opts, tree.toHiccup(opts.ctx));
} else if (implementsFunction(tree, "deref")) {
return normalizeTree(opts, tree.deref());
} else if (isNotStringAndIterable(tree)) {
const res = [];
for (let t of tree) {
Expand Down

0 comments on commit 8ecdd13

Please sign in to comment.