// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import type * as SDK from '../../../../core/sdk/sdk.js';
import type * as Elements from '../../../../panels/elements/components/components.js';

interface CrumbOverrides extends Partial<Elements.Helper.DOMNode> {
  attributes?: Record<string, string|undefined>;
}

let id = 0;
export const makeCrumb = (overrides: CrumbOverrides = {}) => {
  const attributes = overrides.attributes || {};
  const newCrumb: Elements.Helper.DOMNode = {
    nodeType: Node.ELEMENT_NODE,
    id: id++,
    pseudoType: '',
    parentNode: null,
    shadowRootType: '',
    nodeName: 'body',
    nodeNameNicelyCased: 'body',
    legacyDomNode: {} as unknown as SDK.DOMModel.DOMNode,
    highlightNode: () => {},
    clearHighlight: () => {},
    getAttribute: (x: string) => attributes[x] || '',
    ...overrides,
  };
  return newCrumb;
};
