{"record":{"id":"067e2b47bdca6f3f","repo":"perspective-dev/perspective","slug":"custom-element-name-is-already-registered-sk","errorCode":null,"errorMessage":"Custom element \"${name}\" is already registered; skipping duplicate registration (Perspective was loaded more than once on this page).","messagePattern":"Custom element \"(.+?)\" is already registered; skipping duplicate registration \\(Perspective was loaded more than once on this page\\)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/perspective-viewer/src/rust/utils/custom_element.rs","lineNumber":20,"sourceCode":"// ┃ ██████ ██████ ██████       █      █      █      █      █ █▄  ▀███ █       ┃\n// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█  ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄  ▀█ █ ▀▀▀▀▀ ┃\n// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄   █ ▄▄▄▄▄ ┃\n// ┃ █      ██████ █  ▀█▄       █ ██████      █      ███▌▐███ ███████▄ █       ┃\n// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n// ┃ Copyright (c) 2017, the Perspective Authors.                              ┃\n// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃\n// ┃ This file is part of the Perspective library, distributed under the terms ┃\n// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃\n// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n//! Utilities for building JavaScript Custom Elements with Rust.\n\nuse wasm_bindgen::prelude::*;\n\n#[wasm_bindgen(inline_js = r#\"\n    export function bootstrap(psp, name, clsname, statics) {\n        if (customElements.get(name)) {\n            console.warn(`Custom element \"${name}\" is already registered; skipping duplicate registration (Perspective was loaded more than once on this page).`);\n            return;\n        }\n\n        const cls = psp[clsname];\n        const proto = cls.prototype;\n        class x extends HTMLElement {\n            constructor() {\n                super();\n                this._instance = new cls(this);\n            }\n        }\n\n        const names = Object.getOwnPropertyNames(proto);\n        for (const key of names) {\n            if ('get' in Object.getOwnPropertyDescriptor(proto, key)) {\n                Object.defineProperty(x.prototype, key, {\n                    get: function() {\n                        return this._instance[key];","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/perspective-dev/perspective/blob/11c8238c0c9c0b9e490b5a6a2dc277afad1e980a/rust/perspective-viewer/src/rust/utils/custom_element.rs#L2-L38","documentation":"Generic duplicate-registration guard for perspective-viewer custom elements: before defining a custom element named ${name}, the code checks the registry and, if already defined, warns instead of letting customElements.define throw 'already defined'. It indicates the perspective-viewer module was evaluated more than once on the page.","triggerScenarios":"Thrown at rust/perspective-viewer/src/rust/utils/custom_element.rs:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the perspective-viewer bundle is imported/evaluated only once per page","Check bundler config for duplicate chunks or both ESM and UMD builds being loaded","If multiple perspective copies are unavoidable, treat the warning as safe — registration is skipped","Align all perspective package versions to a single build"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"11c8238c0c9c0b9e490b5a6a2dc277afad1e980a","analyzedAt":"2026-09-09T00:35:19.377Z","contentChangedAt":"2026-09-09T00:35:19.377Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}