• 
      

    Allow referencing components by class without pre-registering.

    Review Request #13671 — Created March 26, 2024 and submitted — Latest diff uploaded

    Information

    Ink
    master

    Reviewers

    One of the features of htm is its ability to let you pass in a class
    or function as the tag name, using the following syntax:

    `<${MyComponent} foo="bar">...</>
    

    This is useful for letting you reference a class that may be internal or
    should otherwise not be registered globally. However, while htm
    supported this syntax, Ink didn't know how to handle it.

    Now, Ink will take these and construct them, making the assumption that
    they are valid component classes. They'll get passed any properties and
    children as normal.

    Since these don't have registered names, it also means their
    subcomponents aren't registered. To allow subcomponent usage, a
    subcomponent name can now be prefixed with ., instead of the parent
    component name. In this particular case, the subcomponent's full name
    and function name will be computed dynamically on use, rather than
    during initial registration of the component.

    We otherwise still register and look up subcomponents as normal. I had
    explored consolidating the logic so that the function name and full name
    were always managed at the last possible minute, but that meant that
    they couldn't be looked up as possible candidates separate from
    components or HTML tags during crafting. It's possible parts of this
    will be revisited in the future.

    Unit tests pass.

    Made use of this in in-progress code in Review Board.

    Commits

    Files