Closed ievgennaida closed 2 months ago
Can be also an issue that you need to first cancelAnimationFrame and only then destroy observer.
Cancel animation frame first?
this.observer.destroy();
if (this.measureScheduled > -1)
this.win.cancelAnimationFrame(this.measureScheduled);
this.destroyed = true;
Another exception
TypeError: this.printQuery.addListener is not a function
? DOMObserver.addWindowListeners node_modules/@codemirror/view/dist/index.js:7039:33
? new DOMObserver node_modules/@codemirror/view/dist/index.js:6711:14
? new EditorView node_modules/@codemirror/view/dist/index.js:7414:25
TypeError: this.printQuery.removeListener is not a function
Both functions are deprecated.
Somehow this.win.requestAnimationFrame is starting measurments before observer is actually initialized or set.
The EditorView
constructor synchronously initializes this.observer
, and animation frames run asynchronously, so this isn't really possible unless the requestAnimationFrame
in your test environment is weird.
TypeError: this.printQuery.removeListener is not a function
Here too, if you're running this in a pseudo-browser that doesn't support the standards (in this case MediaQueryList.removeEventListener
or removeListener
), that's not something I'm going to adjust the library for.
Describe the issue
I am trying to run codemirrow from the headless mode using vitest.
versions:
Somehow this.win.requestAnimationFrame is starting measurments before observer is actually initialized or set.
redraw scheduler is started:
Next code is failing while observer is not initialized yet:
Stack trace:
Expected result:
Don't crash application when non critical operation cannot be performed.
Browser and platform
Edge, windows
Reproduction link
See code above.