MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseInsertableFragment

Function parseInsertableFragment

packages/sdk/src/engine/mutate.ts:680–688  ·  view source on GitHub ↗

* Parse an HTML fragment in the target document and return its single root * element, or null when it is empty, multi-root, or contains a . * The dispatch path skips validateOp, so these guards are re-enforced here: * never insert raw , never silently drop extra roots.

(document: Document, html: string)

Source from the content-addressed store, hash-verified

678 * never insert raw <script>, never silently drop extra roots.
679 */
680function parseInsertableFragment(document: Document, html: string): Element | null {
681 // Same temp-div approach as apply-patches.ts to avoid cross-document issues.
682 const tmp = document.createElement("div");
683 tmp.innerHTML = html;
684 if (tmp.querySelector("script")) return null;
685 const node = tmp.firstElementChild;
686 if (!node || node.nextElementSibling) return null;
687 return node;
688}
689
690function handleAddElement(
691 parsed: ParsedDocument,

Callers 1

handleAddElementFunction · 0.85

Calls 1

querySelectorMethod · 0.65

Tested by

no test coverage detected