mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-13 07:01:00 -05:00
Add an id if the user forgot when using py-attribute (#1122)
This commit is contained in:
@@ -156,10 +156,9 @@ export function initHandlers(interpreter: Interpreter) {
|
||||
function createElementsWithEventListeners(interpreter: Interpreter, pyAttribute: string) {
|
||||
const matches: NodeListOf<HTMLElement> = document.querySelectorAll(`[${pyAttribute}]`);
|
||||
for (const el of matches) {
|
||||
// If the element doesn't have an id, let's add one automatically!
|
||||
if (el.id.length === 0) {
|
||||
throw new TypeError(
|
||||
`<${el.tagName.toLowerCase()}> must have an id attribute, when using the ${pyAttribute} attribute`,
|
||||
);
|
||||
ensureUniqueId(el);
|
||||
}
|
||||
const handlerCode = el.getAttribute(pyAttribute);
|
||||
const event = pyAttributeToEvent.get(pyAttribute);
|
||||
|
||||
Reference in New Issue
Block a user