From f3cb423f89419a12ef6fa4b5dcff97a6e2101dc0 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 15 Aug 2026 16:43:11 +0200 Subject: [PATCH 1/2] Enable the `unicorn/no-multiple-promise-resolver-calls` linting rule More information about this rule can be found in the documentation at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-multiple-promise-resolver-calls.md. --- eslint.config.mjs | 1 + gulpfile.mjs | 1 + 2 files changed, 2 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index efe82f60aab81..0fd9ab5b9e65c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -164,6 +164,7 @@ export default [ "unicorn/no-incorrect-query-selector": "error", "unicorn/no-instanceof-builtins": "error", "unicorn/no-invalid-remove-event-listener": "error", + "unicorn/no-multiple-promise-resolver-calls": "error", "unicorn/no-new-buffer": "error", "unicorn/no-single-promise-in-promise-methods": "error", "unicorn/no-typeof-undefined": ["error", { checkGlobalVariables: false }], diff --git a/gulpfile.mjs b/gulpfile.mjs index 535889aaa0a86..0d86e890b8024 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -883,6 +883,7 @@ function runTests(testsName, { bot = false } = {}) { testProcess.on("close", function (code) { if (code !== 0) { reject(new Error(`Running ${testsName} tests failed.`)); + return; } resolve(); }); From d8e5a04cb189e6ef0c676c44da7918b42e845df1 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 16 Aug 2026 10:55:44 +0200 Subject: [PATCH 2/2] Define the visible-page sort function, used in `getVisibleElements`, once When scrolling through long documents, especially when using spread modes and/or wrapped scrolling, the visible-page sorting can be invoked *a lot*. Hence it seems like a good idea to define the sort function just once, rather than re-creating it for every invocation. --- web/ui_utils.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/ui_utils.js b/web/ui_utils.js index 3e1252f67ef63..b7c52ab226b33 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -399,6 +399,11 @@ function backtrackBeforeAllVisibleElements(index, views, top) { return index; } +function visibleSort(a, b) { + const pc = a.percent - b.percent; + return Math.abs(pc) > 0.001 ? -pc : a.id - b.id; // ensure stability +} + /** * @typedef {Object} GetVisibleElementsParameters * @property {HTMLElement} scrollEl - A container that can possibly scroll. @@ -576,13 +581,7 @@ function getVisibleElements({ last = visible.at(-1); if (sortByVisibility) { - visible.sort(function (a, b) { - const pc = a.percent - b.percent; - if (Math.abs(pc) > 0.001) { - return -pc; - } - return a.id - b.id; // ensure stability - }); + visible.sort(visibleSort); } return { first, last, views: visible, ids }; }