'How to get the tagname of a custom element from the outside (or even inside)?

My current approach:

Custom Element:

@customElement("bb-flow-identification")
export class FlowIdentification extends LitElement { /*...*/ }

Other location:

import { FlowIdentification } from "./flow-identification";

// The following yields the name of the class, e.g. 'FlowIdentification'
console.log(FlowIdentification.name);

How can I get the bb-flow-identification tagname from the 'Other location' file? And if that does not work, can I somehow access it from the 'Custom Element' file?

PS: This question is not specific to lit, but I'm having the problem too in the lit framework.



Solution 1:[1]

The exception is thrown because the fetch variable is None, because cur.fetchone() returns None (no data retrieved from the database), therefore that function skips the if and return None

def field(command, *values):
    cur.execute(command, tuple(values))

    if (fetch := cur.fetchone()) is not None:
        return fetch[0]

is equivalent to

def field(command, *values):
    cur.execute(command, tuple(values))

    if (fetch := cur.fetchone()) is not None:
        return fetch[0]
    else:
        return None  # Causing the error

I think it might come from the tuple(values), the variable value is actually already a tuple as you can see in this example, showing that you don't need to call tuple() on your parameter. Try without tuple it might work

>>> def foo(*a):
...     print(tuple(a))
...
>>> foo(5,6)
(5, 6)
>>>
>>> def bar(*a):
...     print(a)
...
>>> bar(5,6)
(5, 6)
>>>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nathan Marotte