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

Function handleSetAttribute

packages/sdk/src/engine/mutate.ts:372–398  ·  view source on GitHub ↗
(
  parsed: ParsedDocument,
  ids: HfId[],
  name: string,
  value: string | null,
)

Source from the content-addressed store, hash-verified

370}
371
372function handleSetAttribute(
373 parsed: ParsedDocument,
374 ids: HfId[],
375 name: string,
376 value: string | null,
377): MutationResult {
378 validateSetAttribute(name, value);
379 const result: MutationResult = { forward: [], inverse: [] };
380 for (const id of ids) {
381 const el = resolveScoped(parsed.document, id);
382 if (!el) continue;
383 const oldValue = el.getAttribute(name);
384 const path = attrPath(id, name);
385 if (value !== null) {
386 el.setAttribute(name, value);
387 const p = scalarChange(path, oldValue, value);
388 result.forward.push(p.forward);
389 result.inverse.push(p.inverse);
390 } else if (oldValue !== null) {
391 el.removeAttribute(name);
392 const p = scalarDelete(path, oldValue);
393 result.forward.push(p.forward);
394 result.inverse.push(p.inverse);
395 }
396 }
397 return result;
398}
399
400// fallow-ignore-next-line complexity
401function handleSetTiming(

Callers 2

applyOpFunction · 0.85
handleMoveElementFunction · 0.85

Calls 7

validateSetAttributeFunction · 0.85
resolveScopedFunction · 0.85
attrPathFunction · 0.85
scalarChangeFunction · 0.85
scalarDeleteFunction · 0.85
getAttributeMethod · 0.65
setAttributeMethod · 0.65

Tested by

no test coverage detected