Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Heines1983 opened this issue Oct 4, 2023 · 0 comments
Open

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

Heines1983 opened this issue Oct 4, 2023 · 0 comments

Comments

@Heines1983
Copy link

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],
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant