aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/components/DashboardRepoList.vue2
-rw-r--r--web_src/js/components/RepoActionView.vue2
-rw-r--r--web_src/js/features/comp/LabelEdit.ts2
-rw-r--r--web_src/js/markup/anchors.ts25
4 files changed, 17 insertions, 14 deletions
diff --git a/web_src/js/components/DashboardRepoList.vue b/web_src/js/components/DashboardRepoList.vue
index 6b16ff9efb..6573633227 100644
--- a/web_src/js/components/DashboardRepoList.vue
+++ b/web_src/js/components/DashboardRepoList.vue
@@ -429,7 +429,7 @@ export default defineComponent({
<svg-icon name="octicon-archive" :size="16"/>
</div>
</a>
- <a class="tw-flex tw-items-center" v-if="repo.latest_commit_status_state" :href="repo.latest_commit_status_state_link" :data-tooltip-content="repo.locale_latest_commit_status_state">
+ <a class="tw-flex tw-items-center" v-if="repo.latest_commit_status_state" :href="repo.latest_commit_status_state_link || null" :data-tooltip-content="repo.locale_latest_commit_status_state">
<!-- the commit status icon logic is taken from templates/repo/commit_status.tmpl -->
<svg-icon :name="statusIcon(repo.latest_commit_status_state)" :class="'tw-ml-2 commit-status icon text ' + statusColor(repo.latest_commit_status_state)" :size="16"/>
</a>
diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue
index aedae4d97f..2eb2211269 100644
--- a/web_src/js/components/RepoActionView.vue
+++ b/web_src/js/components/RepoActionView.vue
@@ -177,7 +177,7 @@ export default defineComponent({
},
},
- async mounted() { // eslint-disable-line @typescript-eslint/no-misused-promises
+ async mounted() {
// load job data and then auto-reload periodically
// need to await first loadJob so this.currentJobStepsStates is initialized and can be used in hashChangeListener
await this.loadJob();
diff --git a/web_src/js/features/comp/LabelEdit.ts b/web_src/js/features/comp/LabelEdit.ts
index 55351cd900..a5bb750cdb 100644
--- a/web_src/js/features/comp/LabelEdit.ts
+++ b/web_src/js/features/comp/LabelEdit.ts
@@ -70,7 +70,7 @@ export function initCompLabelEdit(pageSelector: string) {
form.reportValidity();
return false;
}
- form.submit();
+ form.dispatchEvent(new Event('submit', {bubbles: true}));
},
}).modal('show');
};
diff --git a/web_src/js/markup/anchors.ts b/web_src/js/markup/anchors.ts
index 483d72bd5b..a0d49911fe 100644
--- a/web_src/js/markup/anchors.ts
+++ b/web_src/js/markup/anchors.ts
@@ -5,21 +5,24 @@ const removePrefix = (str: string): string => str.replace(/^user-content-/, '');
const hasPrefix = (str: string): boolean => str.startsWith('user-content-');
// scroll to anchor while respecting the `user-content` prefix that exists on the target
-function scrollToAnchor(encodedId: string): void {
- if (!encodedId) return;
- const id = decodeURIComponent(encodedId);
- const prefixedId = addPrefix(id);
- let el = document.querySelector(`#${prefixedId}`);
+function scrollToAnchor(encodedId?: string): void {
+ // FIXME: need to rewrite this function with new a better markup anchor generation logic, too many tricks here
+ let elemId: string;
+ try {
+ elemId = decodeURIComponent(encodedId ?? '');
+ } catch {} // ignore the errors, since the "encodedId" is from user's input
+ if (!elemId) return;
+
+ const prefixedId = addPrefix(elemId);
+ // eslint-disable-next-line unicorn/prefer-query-selector
+ let el = document.getElementById(prefixedId);
// check for matching user-generated `a[name]`
- if (!el) {
- el = document.querySelector(`a[name="${CSS.escape(prefixedId)}"]`);
- }
+ el = el ?? document.querySelector(`a[name="${CSS.escape(prefixedId)}"]`);
// compat for links with old 'user-content-' prefixed hashes
- if (!el && hasPrefix(id)) {
- return document.querySelector(`#${id}`)?.scrollIntoView();
- }
+ // eslint-disable-next-line unicorn/prefer-query-selector
+ el = (!el && hasPrefix(elemId)) ? document.getElementById(elemId) : el;
el?.scrollIntoView();
}