Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: processed-node-manager is created even in the environment that doesn't need a recorder #1186

Merged
merged 2 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-spoons-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

Fix: processed-node-manager is created even in the environment that doesn't need a recorder
1 change: 1 addition & 0 deletions guide.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ setInterval(save, 10 * 1000);
| collectFonts | false | 是否记录页面中的字体文件 |
| userTriggeredOnInput | false | [什么是 `userTriggered`](https://github.com/rrweb-io/rrweb/pull/495) |
| plugins | [] | 加载插件以获得额外的录制功能. [什么是插件?](./docs/recipes/plugin.zh_CN.md) |
| errorHandler | - | 一个可以定制化处理错误的毁掉函数,它的参数是错误对象。如果 rrweb recorder 内部的某些内容抛出错误,则会调用该回调。 |

#### 隐私

Expand Down
9 changes: 4 additions & 5 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import {
SlimDOMOptions,
createMirror,
} from 'rrweb-snapshot';
import {
initObservers,
mutationBuffers,
processedNodeManager,
} from './observer';
import { initObservers, mutationBuffers } from './observer';
import {
on,
getWindowWidth,
Expand Down Expand Up @@ -36,6 +32,7 @@ import { IframeManager } from './iframe-manager';
import { ShadowDomManager } from './shadow-dom-manager';
import { CanvasManager } from './observers/canvas/canvas-manager';
import { StylesheetManager } from './stylesheet-manager';
import ProcessedNodeManager from './processed-node-manager';
import {
callbackWrapper,
registerErrorHandler,
Expand Down Expand Up @@ -306,6 +303,8 @@ function record<T = eventWithTime>(
});
}

const processedNodeManager = new ProcessedNodeManager();
YunFeng0817 marked this conversation as resolved.
Show resolved Hide resolved

canvasManager = new CanvasManager({
recordCanvas,
mutationCb: wrappedCanvasMutationEmit,
Expand Down
2 changes: 0 additions & 2 deletions packages/rrweb/src/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
selectionCallback,
} from '@rrweb/types';
import MutationBuffer from './mutation';
import ProcessedNodeManager from './processed-node-manager';
import { callbackWrapper } from './error-handler';

type WindowWithStoredMutationObserver = IWindow & {
Expand All @@ -54,7 +53,6 @@ type WindowWithAngularZone = IWindow & {
};

export const mutationBuffers: MutationBuffer[] = [];
export const processedNodeManager = new ProcessedNodeManager();

// Event.path is non-standard and used in some older browsers
type NonStandardEvent = Omit<Event, 'composedPath'> & {
Expand Down
3 changes: 2 additions & 1 deletion packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ export function getInputType(element: HTMLElement): Lowercase<string> | null {
return element.hasAttribute('data-rr-is-password')
? 'password'
: element.hasAttribute('type')
? (element.getAttribute('type')!.toLowerCase() as Lowercase<string>)
? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-non-null-assertion
(element.getAttribute('type')!.toLowerCase() as Lowercase<string>)
: null;
}