mirror of
https://github.com/chenasraf/clarity.git
synced 2026-05-17 17:48:05 +00:00
add a config for disabling mutation throttle
This commit is contained in:
@@ -19,7 +19,8 @@ let config: Config = {
|
||||
upgrade: null,
|
||||
action: null,
|
||||
dob: null,
|
||||
delayDom: false
|
||||
delayDom: false,
|
||||
throttleDom: true
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -17,6 +17,7 @@ import encode from "@src/layout/encode";
|
||||
import * as region from "@src/layout/region";
|
||||
import traverse from "@src/layout/traverse";
|
||||
import processNode from "./node";
|
||||
import config from "@src/core/config";
|
||||
|
||||
let observers: MutationObserver[] = [];
|
||||
let mutations: MutationQueue[] = [];
|
||||
@@ -129,7 +130,7 @@ async function process(): Promise<void> {
|
||||
if (state === Task.Wait) { state = await task.suspend(timer); }
|
||||
if (state === Task.Stop) { break; }
|
||||
let target = mutation.target;
|
||||
let type = track(mutation, timer, instance, record.time);
|
||||
let type = config.throttleDom ? track(mutation, timer, instance, record.time) : mutation.type;
|
||||
if (type && target && target.ownerDocument) { dom.parse(target.ownerDocument); }
|
||||
if (type && target && target.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (target as ShadowRoot).host) { dom.parse(target as ShadowRoot); }
|
||||
switch (type) {
|
||||
|
||||
1
packages/clarity-js/types/core.d.ts
vendored
1
packages/clarity-js/types/core.d.ts
vendored
@@ -138,6 +138,7 @@ export interface Config {
|
||||
action?: (key: string) => void;
|
||||
dob?: number;
|
||||
delayDom?: boolean;
|
||||
throttleDom?: boolean;
|
||||
}
|
||||
|
||||
export const enum Constant {
|
||||
|
||||
Reference in New Issue
Block a user