Skip to content

Commit

Permalink
refactor: export domToVnode and update Request interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Masquerade-Circus committed Sep 22, 2023
1 parent 25920d3 commit 346159f
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 55 deletions.
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export declare const Vnode: VnodeInterface;
export declare function isComponent(component: any): component is Component;
export declare const isVnode: (object?: unknown | VnodeInterface) => object is VnodeInterface;
export declare const isVnodeComponent: (object?: unknown | VnodeComponentInterface) => object is VnodeComponentInterface;
export declare function domToVnode(dom: any): VnodeWithDom;
export declare function trust(htmlString: string): any;
export declare const current: Current;
export declare const reservedProps: Record<string, true>;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ __export(lib_exports, {
current: () => current,
directive: () => directive,
directives: () => directives,
domToVnode: () => domToVnode,
isComponent: () => isComponent,
isNodeJs: () => isNodeJs,
isVnode: () => isVnode,
Expand Down Expand Up @@ -64,16 +65,15 @@ var isVnodeComponent = (object) => {
return isVnode(object) && isComponent(object.tag);
};
function domToVnode(dom) {
if (dom.nodeType === 3) {
let vnode2 = new Vnode(textTag, {}, [dom.nodeValue]);
vnode2.dom = dom;
return vnode2;
}
let children = [];
for (let i = 0, l = dom.childNodes.length; i < l; i++) {
let childDom = dom.childNodes[i];
if (childDom.nodeType === 3) {
let vnode2 = new Vnode(textTag, {}, [childDom.nodeValue]);
vnode2.dom = childDom;
children.push(vnode2);
continue;
}
if (childDom.nodeType === 1) {
if (childDom.nodeType === 1 || childDom.nodeType === 3) {
children.push(domToVnode(childDom));
}
}
Expand Down
Loading

0 comments on commit 346159f

Please sign in to comment.