Patch L.DomEvent.off to swallow errors on canvas element cleanup#37
Patch L.DomEvent.off to swallow errors on canvas element cleanup#37
Conversation
In JSDOM/Node environments with @napi-rs/canvas, Leaflet can fail to remove event listeners from canvas elements because they lack `removeEventListener`. Leaflet then falls back to `detachEvent` (IE legacy path), which also doesn't exist, causing a crash. This patch wraps `L.DomEvent.off` to swallow "detachEvent is not a function" errors, preventing the crash while allowing normal event removal to proceed. * Added `src/polyfills/dom-event.ts` with the patch logic. * Updated `src/index.ts` to apply the patch during initialization. * Verified with reproduction test case.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
- Modified `patchDomEvent` in `src/polyfills/dom-event.ts` to store `originalOff` on `L.DomEvent` instead of capturing it in a closure. This fixes a silent module load failure in Jest/jsdom environments. - Added idempotency check to `patchDomEvent` to prevent re-patching. - Updated `tests/tile-rendering.test.ts` to use `ctx.skip()` instead of `this.skip()` for Vitest compatibility. - Updated `tests/integration.test.ts` to check for network availability before running tests that require external tile servers, skipping them if offline.
Fix patchDomEvent crash and stabilize tests
Patch L.DomEvent.off to swallow errors on canvas element cleanup
In JSDOM/Node environments with @napi-rs/canvas, Leaflet can fail to remove event listeners from canvas elements because they lack
removeEventListener. Leaflet then falls back todetachEvent(IE legacy path), which also doesn't exist, causing a crash.This patch wraps
L.DomEvent.offto swallow "detachEvent is not a function" errors, preventing the crash while allowing normal event removal to proceed.src/polyfills/dom-event.tswith the patch logic.src/index.tsto apply the patch during initialization.PR created automatically by Jules for task 844671179168718025 started by @jburnhams