MCPcopy
hub / github.com/rrweb-io/rrweb / getUntaintedMethod

Function getUntaintedMethod

packages/utils/src/index.ts:173–195  ·  view source on GitHub ↗
(
  key: K,
  instance: BasePrototypeCache[K],
  method: T,
)

Source from the content-addressed store, hash-verified

171// eslint-disable-next-line @typescript-eslint/no-explicit-any
172const untaintedMethodCache: Record<string, BaseMethod<any>> = {};
173export function getUntaintedMethod<
174 K extends keyof BasePrototypeCache,
175 T extends keyof BasePrototypeCache[K],
176>(
177 key: K,
178 instance: BasePrototypeCache[K],
179 method: T,
180): BasePrototypeCache[K][T] {
181 const cacheKey = `${key}.${String(method)}`;
182 if (untaintedMethodCache[cacheKey])
183 return untaintedMethodCache[cacheKey].bind(
184 instance,
185 ) as BasePrototypeCache[K][T];
186
187 const untaintedPrototype = getUntaintedPrototype(key);
188 const untaintedMethod = untaintedPrototype[method];
189
190 if (typeof untaintedMethod !== 'function') return instance[method];
191
192 untaintedMethodCache[cacheKey] = untaintedMethod as BaseMethod<K>;
193
194 return untaintedMethod.bind(instance) as BasePrototypeCache[K][T];
195}
196
197export function ownerDocument(n: Node): Document | null {
198 return getUntaintedAccessor('Node', n, 'ownerDocument');

Callers 2

containsFunction · 0.85
getRootNodeFunction · 0.85

Calls 1

getUntaintedPrototypeFunction · 0.85

Tested by

no test coverage detected