mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 11:09:13 +00:00
Add comment
This commit is contained in:
@@ -106,6 +106,8 @@ export default class ShoelaceElement extends LitElement {
|
||||
if (!currentlyRegisteredConstructor) {
|
||||
// We try to register as the actual class first. If for some reason that fails, we fall back to anonymous classes.
|
||||
// customElements can only have 1 class of the same "object id" per registry, so that is why the try {} catch {} exists.
|
||||
// Some tools like Jest Snapshots and if you import the constructor and call `new SlButton()` they will fail with
|
||||
// the anonymous class version.
|
||||
try {
|
||||
customElements.define(name, elementConstructor, options);
|
||||
} catch (_err) {
|
||||
|
||||
Reference in New Issue
Block a user