Skip to content

SVG and HTML5 <slot> element recognition incomplete #2107

Description

@Widthdom

Summary

Web Components leverage the Shadow DOM and <slot> elements for declarative content projection. Currently, cdidx recognizes custom elements (hyphenated tag names) but does not track <slot> elements or their name attribute, nor does it index which elements are projected via slot="name" attributes. This limits navigation in component codebases: developers cannot easily find all slots offered by a component or all usage sites of a specific slot.

Where

  • src/CodeIndex/Indexer/Symbols/SymbolExtractor.Markup.cs:ExtractHtmlSymbols() — Custom element detection (lines 87–92) recognizes hyphenated tags but treats <slot> as a standard tag, not as a component contract declaration
  • No extraction of slot= attribute values as references or named slot declarations

Suggested approach

  1. Recognize <slot> as a special tag (not a custom element) and extract its name attribute as a "property" symbol (e.g., <slot name="footer"> → symbol kind="property", name="footer")
  2. Extract slot="value" attributes on any element as "reference" symbols pointing to named slot definitions, enabling cross-linking
  3. Consider tracking unnamed default slot separately (e.g., via a synthetic symbol or special naming convention)
  4. Handle default slot content selection (e.g., fallback content inside <slot>) with appropriate body range tracking
  5. Add tests for named slots, unnamed/default slots, multiple slots in one component, and slot projection chains (slot inside slot)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions