UMD Web Utilities Library
    Preparing search index...

    Function createStyledSlotOrClone

    • Creates a slot element or clones the element based on 'styled' attribute

      If the element has a 'styled' attribute, returns a slot reference. Otherwise, clones the element without the slot attribute.

      Parameters

      • element: { element: HTMLElement; slotRef: string }

        The parent element containing the slot

      Returns HTMLElement | null

      Slot element, cloned element, or null if not found

      const container = document.createElement('div');
      const slotElement = document.createElement('div');
      slotElement.setAttribute('slot', 'content');
      slotElement.setAttribute('styled', '');
      container.appendChild(slotElement);

      const result = createStyledSlotOrClone({ element: container, slotRef: 'content' });
      // Returns a slot element for styled content