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

Function applyPatchByTarget

packages/studio/src/utils/sourcePatcher.ts:532–552  ·  view source on GitHub ↗
(html: string, target: PatchTarget, op: PatchOperation)

Source from the content-addressed store, hash-verified

530}
531
532export function applyPatchByTarget(html: string, target: PatchTarget, op: PatchOperation): string {
533 if (target.id) {
534 const patchedById = applyPatch(html, target.id, op);
535 if (patchedById !== html || !target.selector) {
536 return patchedById;
537 }
538 }
539
540 switch (op.type) {
541 case "inline-style":
542 return patchInlineStyleByTarget(html, target, op.property, op.value);
543 case "attribute":
544 return patchAttributeByTarget(html, target, op.property, op.value);
545 case "html-attribute":
546 return patchHtmlAttributeByTarget(html, target, op.property, op.value);
547 case "text-content":
548 return op.value !== null ? patchTextContentByTarget(html, target, op.value) : html;
549 default:
550 return html;
551 }
552}

Callers 5

buildMovePatchesFunction · 0.85
buildResizePatchesFunction · 0.85

Calls 5

applyPatchFunction · 0.85
patchInlineStyleByTargetFunction · 0.85
patchAttributeByTargetFunction · 0.85
patchTextContentByTargetFunction · 0.85

Tested by

no test coverage detected