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

Function applyPatch

packages/studio/src/utils/sourcePatcher.ts:517–530  ·  view source on GitHub ↗
(html: string, elementId: string, op: PatchOperation)

Source from the content-addressed store, hash-verified

515 * Apply a patch operation to an HTML source file.
516 */
517export function applyPatch(html: string, elementId: string, op: PatchOperation): string {
518 switch (op.type) {
519 case "inline-style":
520 return patchInlineStyle(html, elementId, op.property, op.value);
521 case "attribute":
522 return patchAttribute(html, elementId, op.property, op.value);
523 case "html-attribute":
524 return patchHtmlAttribute(html, elementId, op.property, op.value);
525 case "text-content":
526 return op.value !== null ? patchTextContent(html, elementId, op.value) : html;
527 default:
528 return html;
529 }
530}
531
532export function applyPatchByTarget(html: string, target: PatchTarget, op: PatchOperation): string {
533 if (target.id) {

Callers 4

useElementPickerFunction · 0.90
applyPatchByTargetFunction · 0.85

Calls 4

patchInlineStyleFunction · 0.85
patchAttributeFunction · 0.85
patchHtmlAttributeFunction · 0.85
patchTextContentFunction · 0.85

Tested by

no test coverage detected