From 6b926491db59961ecee7273be38a5d3ea33bad60 Mon Sep 17 00:00:00 2001 From: Meghea Iulian Date: Thu, 19 Jan 2023 14:36:38 +0200 Subject: [PATCH] feat(load): set route property on matched elemetn --- src/load.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/load.ts b/src/load.ts index 527dc89..ac3554e 100644 --- a/src/load.ts +++ b/src/load.ts @@ -1,5 +1,5 @@ import { html as htm } from 'haunted'; -import { RuleRet } from './match'; +import { RuleRet, BaseRoute } from './match'; const html: typeof htm = (arr, ...thru) => htm( @@ -42,7 +42,7 @@ export const load = pack: (params: Record) => T, tag: string | ((u: URL) => string) = tagFromPath ) => -

({ match }: P) => { +

({ match, route }: P) => { const url = match.url; const params = { ...match.result?.groups, @@ -51,6 +51,7 @@ export const load = return Promise.resolve(pack(params)).then(() => createElement(typeof tag === 'function' ? tag(url) : tag, { params, + route, }) ); };