Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

571 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */
import { Logger } from "../../utils/Logger";

/**
 * Wrapper for the customElements.define() method to add safety checks.
 */
export function defineCustomElement(
  name: string,
  clazz: CustomElementConstructor,
) {
  if (!window?.customElements) {
    Logger.warn("Custom elements not supported");
    return;
  }

  if (window.customElements.get(name)) {
    if (import.meta.env.PROD) {
      Logger.warn(`Custom element ${name} already defined`);
    }
    return;
  }
  window.customElements.define(name, clazz);
}