add a config for disabling mutation throttle

This commit is contained in:
Swaathee Radhakrishnan
2024-05-10 14:26:29 -07:00
parent 52577706c3
commit 3458ae2192
3 changed files with 5 additions and 2 deletions

View File

@@ -19,7 +19,8 @@ let config: Config = {
upgrade: null,
action: null,
dob: null,
delayDom: false
delayDom: false,
throttleDom: true
};
export default config;

View File

@@ -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) {

View File

@@ -138,6 +138,7 @@ export interface Config {
action?: (key: string) => void;
dob?: number;
delayDom?: boolean;
throttleDom?: boolean;
}
export const enum Constant {