From 0732ba32ee9e9d0677a58469d0cf290ec8d5d1c5 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 21 Mar 2023 02:52:05 +0800 Subject: [PATCH] Polyfill the window.customElements (#23592) (#23595) Backport #23592 Close #23590 It seems that some browsers don't support customElements --- package-lock.json | 11 +++++++++++ package.json | 1 + web_src/js/webcomponents/GiteaOriginUrl.js | 2 ++ 3 files changed, 14 insertions(+) diff --git a/package-lock.json b/package-lock.json index 29335dade1..916087bfb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "17.10.2", "@vue/compiler-sfc": "3.2.45", + "@webcomponents/custom-elements": "1.5.1", "add-asset-webpack-plugin": "2.0.1", "ansi-to-html": "0.7.2", "asciinema-player": "3.0.1", @@ -1822,6 +1823,11 @@ "@xtuc/long": "4.2.2" } }, + "node_modules/@webcomponents/custom-elements": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@webcomponents/custom-elements/-/custom-elements-1.5.1.tgz", + "integrity": "sha512-6T/XT3S1UHDlRWFSxRXdeSoYWczEl78sygNPS7jDyHVrfZcF/pUtWGYgxF4uviH59iPVw1eOWbhubm8CqO0MpA==" + }, "node_modules/@webpack-cli/configtest": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.0.1.tgz", @@ -11268,6 +11274,11 @@ "@xtuc/long": "4.2.2" } }, + "@webcomponents/custom-elements": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@webcomponents/custom-elements/-/custom-elements-1.5.1.tgz", + "integrity": "sha512-6T/XT3S1UHDlRWFSxRXdeSoYWczEl78sygNPS7jDyHVrfZcF/pUtWGYgxF4uviH59iPVw1eOWbhubm8CqO0MpA==" + }, "@webpack-cli/configtest": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.0.1.tgz", diff --git a/package.json b/package.json index afc7752257..5fb053beab 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "17.10.2", "@vue/compiler-sfc": "3.2.45", + "@webcomponents/custom-elements": "1.5.1", "add-asset-webpack-plugin": "2.0.1", "ansi-to-html": "0.7.2", "asciinema-player": "3.0.1", diff --git a/web_src/js/webcomponents/GiteaOriginUrl.js b/web_src/js/webcomponents/GiteaOriginUrl.js index 47fd13bfc1..c8736ac5c5 100644 --- a/web_src/js/webcomponents/GiteaOriginUrl.js +++ b/web_src/js/webcomponents/GiteaOriginUrl.js @@ -1,3 +1,5 @@ +import '@webcomponents/custom-elements'; // automatically adds custom elements for older browsers that don't support it + // this is a Gitea's private HTML component, it converts an absolute or relative URL to an absolute URL with the current origin window.customElements.define('gitea-origin-url', class extends HTMLElement { connectedCallback() {