Skip to content

Commit

Permalink
fix: routing FF + safari
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBLT committed Mar 29, 2024
1 parent 01ee65a commit 5c1ec17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/@hec.js/ui/lib/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @returns {Expression}
*/
export function expression(text) {
const parts = text.matchAll(/([^ {}\s]+)/g),
const parts = text.matchAll(/([a-z]+=["'][^'"]+["']|[^{}\s]+)/g),
exp = {
meta: {},
text: text,
Expand Down
7 changes: 0 additions & 7 deletions packages/@hec.js/ui/lib/src/plugins/data-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ export const dataRoutePlugin = {
select: (node) => node.matches('[data-route]'),

run: async (node, props) => {

/* -- Polyfill safari -- */
if (!('URLPattern' in window)) { // @ts-ignore
await import('https://kevinblt.github.io/hec/packages/@hec.js/ui/dist/urlpattnern.min.js');
}
/* -- -- */

const route = node.dataset.route,
placeholder = document.createComment('route: ' + route),
update = nodeUpdater(node, placeholder, props);
Expand Down
6 changes: 6 additions & 0 deletions packages/@hec.js/ui/lib/src/routing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { onMount } from "./notify.js";
import { signal } from "./signal.js";

/* -- Polyfill safari -- */
if (!('URLPattern' in window)) { // @ts-ignore
await import('https://kevinblt.github.io/hec/packages/@hec.js/ui/dist/urlpattnern.min.js');
}
/* -- -- */

/** @type { import("./signal.js").Signal<{ [key: string]: string }> } */
export const query = signal({});
export const route = signal(location.pathname);
Expand Down

0 comments on commit 5c1ec17

Please sign in to comment.