MCPcopy Create free account
hub / github.com/SplootCode/splootcode / createNodeFromDomNode

Function createNodeFromDomNode

packages/language-web/code_io/import_html.ts:68–81  ·  view source on GitHub ↗
(domNode: ChildNode)

Source from the content-addressed store, hash-verified

66}
67
68function createNodeFromDomNode(domNode: ChildNode): SplootNode {
69 switch (domNode.nodeType) {
70 case Node.ELEMENT_NODE:
71 return createDomElement(domNode as Element)
72 case Node.TEXT_NODE:
73 return createTextNode(domNode as Text)
74 case Node.COMMENT_NODE:
75 // TODO
76 break
77 default:
78 console.log('Unknown node type: ', domNode)
79 }
80 return null
81}
82
83export function parseHtml(source: string): SplootNode {
84 const parser = new DOMParser()

Callers 2

createDomElementFunction · 0.85
parseHtmlFunction · 0.85

Calls 2

createDomElementFunction · 0.85
createTextNodeFunction · 0.85

Tested by

no test coverage detected