@iyulab/router 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.3] - 2026-04-24
4
+
5
+ ### Fixed
6
+ - Document click handler now scopes interception to the router's `_rootElement` instead of `document`, preventing accidental capture of clicks outside the router's DOM subtree
7
+ - Click handler no longer intercepts same-origin anchors pointing outside `basepath` — when `basepath` is not `/`, links targeting paths outside the basepath are passed through to browser navigation instead of falling through to the fallback route
8
+
3
9
  ## [0.9.2] - 2026-04-13
4
10
 
5
11
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -382,7 +382,7 @@ export declare class Router {
382
382
  /** 브라우저 히스토리 이벤트가 발생시 라우팅 처리 */
383
383
  private handleWindowPopstate;
384
384
  /** 클릭 이벤트에서 라우터로 처리할 앵커를 찾아 클라이언트 라우팅 수행 */
385
- private handleDocumentClick;
385
+ private handleRootElementClick;
386
386
  }
387
387
 
388
388
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as isExternalUrl, i as absolutePath, n as __decorate, o as parseUrl, r as __decorateMetadata, s as UOutlet, t as ULink } from "./share-CEEpCf48.js";
1
+ import { a as isExternalUrl, i as absolutePath, n as __decorate, o as parseUrl, r as __decorateMetadata, s as UOutlet, t as ULink } from "./share-DC0R4F2d.js";
2
2
  import { LitElement, css, html } from "lit";
3
3
  import { customElement, property } from "lit/decorators.js";
4
4
  //#region src/types/RouteError.ts
@@ -390,7 +390,7 @@ var Router = class {
390
390
  this.handleWindowPopstate = async (_) => {
391
391
  await this.go(window.location.href);
392
392
  };
393
- this.handleDocumentClick = async (e) => {
393
+ this.handleRootElementClick = async (e) => {
394
394
  try {
395
395
  if (e.defaultPrevented) return;
396
396
  if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey) return;
@@ -402,6 +402,7 @@ var Router = class {
402
402
  if (anchor.hasAttribute("download")) return;
403
403
  if (anchor.getAttribute("rel") === "external") return;
404
404
  if (anchor.target && anchor.target !== "") return;
405
+ if (this._basepath !== "/" && !new URL(anchor.href).pathname.startsWith(this._basepath)) return;
405
406
  e.preventDefault();
406
407
  await this.go(anchor.href);
407
408
  } catch {}
@@ -413,7 +414,7 @@ var Router = class {
413
414
  this._fallback = config.fallback;
414
415
  this._enter = config.enter;
415
416
  window.addEventListener("popstate", this.handleWindowPopstate);
416
- if (config.useIntercept !== false) document.addEventListener("click", this.handleDocumentClick);
417
+ if (config.useIntercept !== false) this._rootElement.addEventListener("click", this.handleRootElementClick);
417
418
  if (config.initialLoad !== false) waitOutlet(this._rootElement).then(() => {
418
419
  this.go(window.location.href);
419
420
  });
@@ -421,7 +422,7 @@ var Router = class {
421
422
  /** 객체를 정리하고 이벤트 리스너를 제거합니다. */
422
423
  destroy() {
423
424
  window.removeEventListener("popstate", this.handleWindowPopstate);
424
- document.removeEventListener("click", this.handleDocumentClick);
425
+ this._rootElement?.removeEventListener("click", this.handleRootElementClick);
425
426
  this._requestID = void 0;
426
427
  this._context = void 0;
427
428
  }
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as UOutlet$1, t as ULink$1 } from "./share-CEEpCf48.js";
1
+ import { s as UOutlet$1, t as ULink$1 } from "./share-DC0R4F2d.js";
2
2
  import React from "react";
3
3
  import { createComponent } from "@lit/react";
4
4
  //#region src/react.ts
@@ -126,12 +126,12 @@ function catchBasepath(basepath) {
126
126
  return basepath;
127
127
  }
128
128
  //#endregion
129
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateMetadata.js
129
+ //#region \0@oxc-project+runtime@0.127.0/helpers/decorateMetadata.js
130
130
  function __decorateMetadata(k, v) {
131
131
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
132
132
  }
133
133
  //#endregion
134
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
134
+ //#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
135
135
  function __decorate(decorators, target, key, desc) {
136
136
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
137
137
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/router",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "A modern client-side router for web applications with support for Lit and React components",
5
5
  "keywords": [
6
6
  "lit",
@@ -58,11 +58,11 @@
58
58
  }
59
59
  },
60
60
  "devDependencies": {
61
- "@types/node": "^25.5.0",
61
+ "@types/node": "^25.6.0",
62
62
  "@types/react": "^19.2.14",
63
63
  "@types/react-dom": "^19.2.3",
64
64
  "typescript": "^5.9.3",
65
- "vite": "^8.0.3",
65
+ "vite": "^8.0.8",
66
66
  "vite-plugin-dts": "^4.5.4"
67
67
  }
68
68
  }
@@ -5,7 +5,7 @@ license: MIT
5
5
  compatibility: Browser environments only (requires URLPattern and History API)
6
6
  metadata:
7
7
  author: iyulab
8
- version: "0.9.2"
8
+ version: "0.9.3"
9
9
  ---
10
10
 
11
11
  # @iyulab/router