Skip to content

The open alternative to Salesforce, designed for AI.

457 B
Raw Blame
import { collectAncestorChainFromRootToNode } from '@/polyfills/dom/utils/collectAncestorChainFromRootToNode';
import { definePolyfillMethod } from '@/polyfills/utils/definePolyfillMethod';

export const installGetRootNodePolyfill = (nodePrototype: object): void => {
  definePolyfillMethod({
    target: nodePrototype,
    methodName: 'getRootNode',
    method: (node: object): object =>
      collectAncestorChainFromRootToNode(node)[0] ?? node,
  });
};