Skip to content

Commit

Permalink
Handle errors when attempting to create invalid elements (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusLongmuir authored Jun 27, 2023
1 parent 5f56ce9 commit 60450fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/networked-dom-web/src/NetworkedDOMWebsocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,13 @@ export class NetworkedDOMWebsocket {
return textNode;
}

const element = document.createElement(tag);
let element;
try {
element = document.createElement(tag);
} catch (e) {
console.error(`Error creating element: (${tag})`, e);
element = document.createElement("div");
}
this.idToElement.set(nodeId, element);
this.elementToId.set(element, nodeId);
for (const key in attributes) {
Expand Down

0 comments on commit 60450fd

Please sign in to comment.