From 364eeffcc45fd6c4b053a7fdc7d1c8598c45c565 Mon Sep 17 00:00:00 2001 From: Cindy Hill <110551331+cinderellasecure@users.noreply.github.com> Date: Thu, 30 Oct 2025 12:07:03 -0600 Subject: [PATCH 01/12] Potential fix for code scanning alert no. 3: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/lighthouse.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml index 7cd07238..c7bb0d2c 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse.yml @@ -1,4 +1,6 @@ name: Lighthouse +permissions: + contents: read on: [pull_request] From ee2e1379ba33a6c5e88eeae0446e61c36649f491 Mon Sep 17 00:00:00 2001 From: Cindy Hill <110551331+cinderellasecure@users.noreply.github.com> Date: Thu, 30 Oct 2025 12:07:04 -0600 Subject: [PATCH 02/12] Potential fix for code scanning alert no. 4: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/nodejs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6d84019f..20993d56 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,4 +1,6 @@ name: Build +permissions: + contents: read on: pull_request: From 201fdab1b56a81c4c588b743bd54ca5207d37900 Mon Sep 17 00:00:00 2001 From: Cindy Hill <110551331+cinderellasecure@users.noreply.github.com> Date: Thu, 30 Oct 2025 12:07:05 -0600 Subject: [PATCH 03/12] Potential fix for code scanning alert no. 5: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 264bdd37..fe88fc50 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,6 @@ name: Publish +permissions: + contents: read on: release: From bd9591ce72eb5e048b603a3b76f84b846364d2a5 Mon Sep 17 00:00:00 2001 From: Dusty Greif Date: Mon, 9 Feb 2026 12:02:59 -0500 Subject: [PATCH 04/12] Remove change from publish workflow --- .github/workflows/publish.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8e70b474..8d40ed48 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,4 @@ name: Publish -permissions: - contents: read on: release: From 65429ec34dc7d9ece6e2e093022506b4feb6f34d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:31:20 +0000 Subject: [PATCH 05/12] Bump the bundler group across 1 directory with 3 updates Bumps the bundler group with 3 updates in the /docs directory: [commonmarker](https://github.com/gjtorikian/commonmarker), [faraday](https://github.com/lostisland/faraday) and [rexml](https://github.com/ruby/rexml). Updates `commonmarker` from 0.23.7 to 0.23.10 - [Release notes](https://github.com/gjtorikian/commonmarker/releases) - [Changelog](https://github.com/gjtorikian/commonmarker/blob/v0.23.10/CHANGELOG.md) - [Commits](https://github.com/gjtorikian/commonmarker/compare/v0.23.7...v0.23.10) Updates `faraday` from 1.10.0 to 1.10.5 - [Release notes](https://github.com/lostisland/faraday/releases) - [Changelog](https://github.com/lostisland/faraday/blob/main/CHANGELOG.md) - [Commits](https://github.com/lostisland/faraday/compare/v1.10.0...v1.10.5) Updates `rexml` from 3.2.5 to 3.4.2 - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.5...v3.4.2) --- updated-dependencies: - dependency-name: commonmarker dependency-version: 0.23.10 dependency-type: indirect dependency-group: bundler - dependency-name: faraday dependency-version: 1.10.5 dependency-type: indirect dependency-group: bundler - dependency-name: rexml dependency-version: 3.4.2 dependency-type: indirect dependency-group: bundler ... Signed-off-by: dependabot[bot] --- docs/Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 55e2a9cf..52f40551 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -4,13 +4,13 @@ GEM addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) colorator (1.1.0) - commonmarker (0.23.7) + commonmarker (0.23.10) concurrent-ruby (1.1.10) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) - faraday (1.10.0) + faraday (1.10.5) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -23,12 +23,12 @@ GEM faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) + faraday-em_synchrony (1.0.1) faraday-excon (1.1.0) faraday-httpclient (1.0.1) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) - faraday-net_http (1.0.1) + faraday-multipart (1.2.0) + multipart-post (~> 2.0) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) @@ -74,7 +74,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.3.6) - multipart-post (2.1.1) + multipart-post (2.4.1) octokit (4.22.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) @@ -84,7 +84,7 @@ GEM rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) - rexml (3.2.5) + rexml (3.4.2) rouge (3.28.0) ruby2_keywords (0.0.5) safe_yaml (1.0.5) From 341b3bd3e099bad43c9e043b6dc79e287761a9a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:30:15 +0000 Subject: [PATCH 06/12] Bump on-headers in the npm_and_yarn group across 1 directory Bumps the npm_and_yarn group with 1 update in the / directory: [on-headers](https://github.com/jshttp/on-headers). Updates `on-headers` from 1.0.2 to 1.1.0 - [Release notes](https://github.com/jshttp/on-headers/releases) - [Changelog](https://github.com/jshttp/on-headers/blob/master/HISTORY.md) - [Commits](https://github.com/jshttp/on-headers/compare/v1.0.2...v1.1.0) --- updated-dependencies: - dependency-name: on-headers dependency-version: 1.1.0 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] --- package-lock.json | 123 +++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 77 deletions(-) diff --git a/package-lock.json b/package-lock.json index 457970e9..04e1583a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3080,16 +3080,6 @@ "npm": "1.2.8000 || >= 1.4.16" } }, - "node_modules/body-parser/node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/body-parser/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -3170,10 +3160,11 @@ } }, "node_modules/bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -3642,17 +3633,18 @@ } }, "node_modules/compression": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.4.tgz", - "integrity": "sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.1.tgz", + "integrity": "sha512-9mAqGPHLakhCLeNyxPkK4xVo746zQ/czLH1Ky+vkitMnWfWZps8r0qXuwhwizagCRttsL4lfG4pIOvaWLpAP0w==", "dev": true, + "license": "MIT", "dependencies": { - "accepts": "~1.3.5", - "bytes": "3.0.0", - "compressible": "~2.0.16", + "bytes": "3.1.2", + "compressible": "~2.0.18", "debug": "2.6.9", - "on-headers": "~1.0.2", - "safe-buffer": "5.1.2", + "negotiator": "~0.6.4", + "on-headers": "~1.1.0", + "safe-buffer": "5.2.1", "vary": "~1.1.2" }, "engines": { @@ -3674,6 +3666,16 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/compression/node_modules/negotiator": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", + "integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3710,26 +3712,6 @@ "node": ">= 0.6" } }, - "node_modules/content-disposition/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, "node_modules/content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", @@ -5429,26 +5411,6 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "node_modules/express/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -8048,10 +8010,11 @@ } }, "node_modules/on-headers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", - "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz", + "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.8" } @@ -8625,15 +8588,6 @@ "node": ">= 0.8" } }, - "node_modules/raw-body/node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -8930,10 +8884,25 @@ "dev": true }, "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" }, "node_modules/safer-buffer": { "version": "2.1.2", From ecade8923f3b54ea0a2b14a2a02c802554b79244 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:43:01 +0000 Subject: [PATCH 07/12] Bump minimatch in the npm_and_yarn group across 1 directory Bumps the npm_and_yarn group with 1 update in the / directory: [minimatch](https://github.com/isaacs/minimatch). Updates `minimatch` from 3.1.2 to 3.1.5 - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] --- package-lock.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04e1583a..2a1ec106 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7742,10 +7742,11 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, From ace34fa35a17f858382d5fd1e616616e088833b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:10:20 +0000 Subject: [PATCH 08/12] Bump lodash in the npm_and_yarn group across 1 directory Bumps the npm_and_yarn group with 1 update in the / directory: [lodash](https://github.com/lodash/lodash). Updates `lodash` from 4.17.21 to 4.18.1 - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] --- package-lock.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2a1ec106..0a909356 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7475,15 +7475,16 @@ } }, "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "dev": true, + "license": "MIT" }, "node_modules/lodash-es": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz", - "integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==", "dev": true, "license": "MIT" }, From c95922aed579dc3a02283f03357de0a1ee04bc57 Mon Sep 17 00:00:00 2001 From: Alexander Lelidis Date: Thu, 16 Apr 2026 15:50:48 +0200 Subject: [PATCH 09/12] fix: coalesce scan() into a single rAF to avoid paint delay on bulk DOM mutations Replace per-element WeakMap+rAF deduplication with a shared Set of pending elements and a single requestAnimationFrame timer. When many elements are added in one frame (e.g. framework list rendering), only one rAF callback now runs before paint instead of one per element. Fixes #343 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/lazy-define.ts | 25 ++++++++++++++++--------- test/lazy-define.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/lazy-define.ts b/src/lazy-define.ts index 016b8865..a97c616d 100644 --- a/src/lazy-define.ts +++ b/src/lazy-define.ts @@ -57,26 +57,33 @@ const strategies: Record = { type ElementLike = Element | Document | ShadowRoot -const timers = new WeakMap() +const pendingElements = new Set() +let scanTimer: number | null = null + function scan(element: ElementLike) { - cancelAnimationFrame(timers.get(element) || 0) - timers.set( - element, - requestAnimationFrame(() => { + pendingElements.add(element) + if (scanTimer != null) return + scanTimer = requestAnimationFrame(() => { + scanTimer = null + if (!dynamicElements.size) { + pendingElements.clear() + return + } + for (const el of pendingElements) { for (const tagName of dynamicElements.keys()) { const child: Element | null = - element instanceof Element && element.matches(tagName) ? element : element.querySelector(tagName) + el instanceof Element && el.matches(tagName) ? el : el.querySelector(tagName) if (customElements.get(tagName) || child) { const strategyName = (child?.getAttribute('data-load-on') || 'ready') as keyof typeof strategies const strategy = strategyName in strategies ? strategies[strategyName] : strategies.ready // eslint-disable-next-line github/no-then for (const cb of dynamicElements.get(tagName) || []) strategy(tagName).then(cb) dynamicElements.delete(tagName) - timers.delete(element) } } - }) - ) + } + pendingElements.clear() + }) } let elementLoader: MutationObserver diff --git a/test/lazy-define.ts b/test/lazy-define.ts index b2517d67..5e49abaa 100644 --- a/test/lazy-define.ts +++ b/test/lazy-define.ts @@ -68,6 +68,38 @@ describe('lazyDefine', () => { expect(onDefine3).to.have.callCount(1) }) + it('coalesces multiple added elements into a single rAF callback', async () => { + const onDefine = spy() + lazyDefine('coalesce-test-element', onDefine) + + const rafSpy = spy(window, 'requestAnimationFrame') + const callsBefore = rafSpy.callCount + + await fixture(html` +
+ + + + + + + + + + +
+ `) + + await animationFrame() + + const rafCallsFromScan = rafSpy.callCount - callsBefore + rafSpy.restore() + + // Should use at most a few rAF calls, not one per element + expect(rafCallsFromScan).to.be.lessThan(5) + expect(onDefine).to.be.callCount(1) + }) + it('lazy loads elements in shadow roots', async () => { const onDefine = spy() lazyDefine('nested-shadow-element', onDefine) From 0114d5e12852beeb4754167418623a7088cf1e2f Mon Sep 17 00:00:00 2001 From: Alexander Lelidis Date: Thu, 16 Apr 2026 15:53:30 +0200 Subject: [PATCH 10/12] style: fix prettier formatting Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/lazy-define.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lazy-define.ts b/src/lazy-define.ts index a97c616d..93243ef8 100644 --- a/src/lazy-define.ts +++ b/src/lazy-define.ts @@ -71,8 +71,7 @@ function scan(element: ElementLike) { } for (const el of pendingElements) { for (const tagName of dynamicElements.keys()) { - const child: Element | null = - el instanceof Element && el.matches(tagName) ? el : el.querySelector(tagName) + const child: Element | null = el instanceof Element && el.matches(tagName) ? el : el.querySelector(tagName) if (customElements.get(tagName) || child) { const strategyName = (child?.getAttribute('data-load-on') || 'ready') as keyof typeof strategies const strategy = strategyName in strategies ? strategies[strategyName] : strategies.ready From 64cb060868dff54f8af35e8326834ece43ca2c59 Mon Sep 17 00:00:00 2001 From: Alexander Lelidis Date: Mon, 20 Apr 2026 14:11:25 +0200 Subject: [PATCH 11/12] address pr comments --- src/lazy-define.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lazy-define.ts b/src/lazy-define.ts index 93243ef8..2109f5fe 100644 --- a/src/lazy-define.ts +++ b/src/lazy-define.ts @@ -6,14 +6,14 @@ const ready = new Promise(resolve => { if (document.readyState !== 'loading') { resolve() } else { - document.addEventListener('readystatechange', () => resolve(), {once: true}) + document.addEventListener('readystatechange', () => resolve(), { once: true }) } }) const firstInteraction = new Promise(resolve => { const controller = new AbortController() controller.signal.addEventListener('abort', () => resolve()) - const listenerOptions = {once: true, passive: true, signal: controller.signal} + const listenerOptions = { once: true, passive: true, signal: controller.signal } const handler = () => controller.abort() document.addEventListener('mousedown', handler, listenerOptions) @@ -65,11 +65,12 @@ function scan(element: ElementLike) { if (scanTimer != null) return scanTimer = requestAnimationFrame(() => { scanTimer = null + const elements = new Set(pendingElements) + pendingElements.clear() if (!dynamicElements.size) { - pendingElements.clear() return } - for (const el of pendingElements) { + outer: for (const el of elements) { for (const tagName of dynamicElements.keys()) { const child: Element | null = el instanceof Element && el.matches(tagName) ? el : el.querySelector(tagName) if (customElements.get(tagName) || child) { @@ -78,10 +79,10 @@ function scan(element: ElementLike) { // eslint-disable-next-line github/no-then for (const cb of dynamicElements.get(tagName) || []) strategy(tagName).then(cb) dynamicElements.delete(tagName) + if (!dynamicElements.size) break outer } } } - pendingElements.clear() }) } @@ -91,7 +92,7 @@ export function lazyDefine(object: Record void>): void export function lazyDefine(tagName: string, callback: () => void): void export function lazyDefine(tagNameOrObj: string | Record void>, singleCallback?: () => void) { if (typeof tagNameOrObj === 'string' && singleCallback) { - tagNameOrObj = {[tagNameOrObj]: singleCallback} + tagNameOrObj = { [tagNameOrObj]: singleCallback } } for (const [tagName, callback] of Object.entries(tagNameOrObj)) { if (!dynamicElements.has(tagName)) dynamicElements.set(tagName, new Set<() => void>()) @@ -112,5 +113,5 @@ export function observe(target: ElementLike): void { scan(target) - elementLoader.observe(target, {subtree: true, childList: true}) + elementLoader.observe(target, { subtree: true, childList: true }) } From f52fee6d94801b54b3dda3796e1a58163b5eab80 Mon Sep 17 00:00:00 2001 From: Alexander Lelidis Date: Mon, 20 Apr 2026 14:13:41 +0200 Subject: [PATCH 12/12] lint --- src/lazy-define.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lazy-define.ts b/src/lazy-define.ts index 2109f5fe..755c3e61 100644 --- a/src/lazy-define.ts +++ b/src/lazy-define.ts @@ -6,14 +6,14 @@ const ready = new Promise(resolve => { if (document.readyState !== 'loading') { resolve() } else { - document.addEventListener('readystatechange', () => resolve(), { once: true }) + document.addEventListener('readystatechange', () => resolve(), {once: true}) } }) const firstInteraction = new Promise(resolve => { const controller = new AbortController() controller.signal.addEventListener('abort', () => resolve()) - const listenerOptions = { once: true, passive: true, signal: controller.signal } + const listenerOptions = {once: true, passive: true, signal: controller.signal} const handler = () => controller.abort() document.addEventListener('mousedown', handler, listenerOptions) @@ -92,7 +92,7 @@ export function lazyDefine(object: Record void>): void export function lazyDefine(tagName: string, callback: () => void): void export function lazyDefine(tagNameOrObj: string | Record void>, singleCallback?: () => void) { if (typeof tagNameOrObj === 'string' && singleCallback) { - tagNameOrObj = { [tagNameOrObj]: singleCallback } + tagNameOrObj = {[tagNameOrObj]: singleCallback} } for (const [tagName, callback] of Object.entries(tagNameOrObj)) { if (!dynamicElements.has(tagName)) dynamicElements.set(tagName, new Set<() => void>()) @@ -113,5 +113,5 @@ export function observe(target: ElementLike): void { scan(target) - elementLoader.observe(target, { subtree: true, childList: true }) + elementLoader.observe(target, {subtree: true, childList: true}) }