Function

applyMetaToElement

@ng-forge/dynamic-forms

Applies meta attributes to a DOM element and tracks which attributes were applied.

This utility handles: - Removing previously applied attributes that are no longer in meta - Setting new attributes from meta - Converting all values to strings via String()

Signature

function applyMetaToElement(
  element: Element,
  meta: FieldMeta,
  previouslyApplied: Set<string>
): Set<string>

Parameters

NameTypeDescription
elementElement- The DOM element to apply attributes to
metaFieldMeta- The meta object containing attributes to apply
previouslyAppliedSet<string>- Set of attribute names that were previously applied

Returns

Set<string>

Examples

private appliedAttrs = new Set<string>();

explicitEffect([this.meta], ([meta]) => {
  const input = this.el.nativeElement.querySelector('input');
  if (input) {
    this.appliedAttrs = applyMetaToElement(input, meta, this.appliedAttrs);
  }
});