( key: K, instance: BasePrototypeCache[K], method: T, )
| 171 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 172 | const untaintedMethodCache: Record<string, BaseMethod<any>> = {}; |
| 173 | export 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 | |
| 197 | export function ownerDocument(n: Node): Document | null { |
| 198 | return getUntaintedAccessor('Node', n, 'ownerDocument'); |
no test coverage detected