Skip to content

Add support for loading (a) harness(es) on a component  #258

Description

@Heines1983

It would be great of a harness could also be loaded within a specific component instead of the document root. Now I've added myself two methods but it would of course be better if its included in the package. My code at the moment:

export function getHarnessForComponent<HARNESS extends ComponentHarness, COMPONENT extends ContentContainerComponentHarness<string>>(
    query: HarnessQuery<HARNESS>, component: ChainableHarness<COMPONENT>
): ChainableHarness<HARNESS> {
    return new Proxy<ChainableHarness<HARNESS>>({} as any, {
        get: (_, prop) =>
            (addHarnessMethodsToChainer(component.getHarness(query) as ChainableHarness<HARNESS>) as any)[prop],
    });
}
export function getAllHarnessesForComponent<HARNESS extends ComponentHarness, COMPONENT extends ContentContainerComponentHarness<string>>(
    query: HarnessQuery<HARNESS>, component: ChainableHarness<COMPONENT>
): ChainableHarness<HARNESS[]> {

    return new Proxy<ChainableHarness<HARNESS[]>>({} as any, {
        get: (_, prop) => (component.getAllHarnesses(query) as any as ChainableHarness<HARNESS[]> as any)[prop],
    });
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions