Skip to content

Commit

Permalink
7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xeaone committed Jun 29, 2022
1 parent 1c62a45 commit 683fd65
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 312 deletions.
3 changes: 3 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if [ "$VERSION" = "" ]; then
exit
fi

rm -r docs/*
cp -r web/. docs/.

deno bundle src/router/router.ts pro/x-router.js
deno bundle src/element/element.ts pro/x-element.js

Expand Down
2 changes: 1 addition & 1 deletion docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<base href="/">
<script>document.querySelector('base').href = window.location.hostname === 'xeaone.github.io' ? '/element/' : '/';</script>
<script>document.querySelector('base').href = window.location.pathname.startsWith('/element') ? '/element/' : '/';</script>
<meta charset="UTF-8">
<meta name="theme-color" content="#2299ff">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<base href="/">
<script>document.querySelector('base').href = window.location.hostname === 'xeaone.github.io' ? '/element/' : '/';</script>
<script>document.querySelector('base').href = window.location.pathname.startsWith('/element') ? '/element/' : '/';</script>
<meta charset="UTF-8">
<meta name="theme-color" content="#2299ff">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
186 changes: 93 additions & 93 deletions docs/x-element.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions docs/x-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class XRouter extends HTMLElement {
search: parser.search,
protocol: parser.protocol,
hostname: parser.hostname,
pathname: parser.pathname
pathname: `${parser.origin}${parser.pathname.replace(/\/$/, '')}`.replace(document.baseURI.replace(/\/$/, ''), '') || '/'
};
}
async #go(path, options) {
Expand Down Expand Up @@ -178,19 +178,19 @@ class XRouter extends HTMLElement {
if (this.#onAfter) await this.#onAfter(location, element);
}
async #state(event) {
const { href , pathname } = this.#location(event?.state?.href || window.location.href);
if (!href.startsWith(window.location.origin)) return;
const { href: href1 , pathname } = this.#location(event?.state?.href || window.location.href);
if (!href1.startsWith(window.location.origin)) return;
if (this.#paths.length && !this.#paths.includes(pathname)) return;
await this.replace(href);
await this.replace(href1);
globalThis.scroll(event?.state?.top || 0, 0);
}
async #click(event1, element) {
async #click(event1, element1) {
if (event1.defaultPrevented || event1.button !== 0 || event1.altKey || event1.ctrlKey || event1.metaKey || event1.shiftKey) return;
if (element.hasAttribute('download') || element.hasAttribute('external') || element.hasAttribute('target') || element.href.startsWith('tel:') || element.href.startsWith('ftp:') || element.href.startsWith('file:)') || element.href.startsWith('mailto:') || !element.href.startsWith(window.location.origin)) return;
if (this.#paths.length && !this.#paths.includes(element.pathname)) return;
if (element1.hasAttribute('download') || element1.hasAttribute('external') || element1.hasAttribute('target') || element1.href.startsWith('tel:') || element1.href.startsWith('ftp:') || element1.href.startsWith('file:)') || element1.href.startsWith('mailto:') || !element1.href.startsWith(window.location.origin)) return;
if (this.#paths.length && !this.#paths.includes(element1.pathname)) return;
event1.preventDefault();
if (element.href === window.location.href) return;
await this.assign(element.href);
if (element1.href === window.location.href) return;
await this.assign(element1.href);
globalThis.scroll(0, 0);
}
async connectedCallback() {
Expand Down
Loading

0 comments on commit 683fd65

Please sign in to comment.