fix(inspector): fix leaking event listeners (#22535)

Fixes https://github.com/microsoft/playwright/issues/22348
This commit is contained in:
Max Schmitt 2023-04-20 22:42:34 +02:00 committed by GitHub
parent 2b9b46e260
commit 58b3c31f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,7 +107,7 @@ export const CodeMirrorWrapper: React.FC<SourceProps> = ({
React.useEffect(() => {
if (!codemirror)
return;
codemirror.off('change', (codemirror as any).listenerSymbol);
codemirror.off('change', (codemirror as any)[listenerSymbol]);
(codemirror as any)[listenerSymbol] = undefined;
if (onChange) {
(codemirror as any)[listenerSymbol] = () => onChange(codemirror.getValue());