Skip to content

Commit ed568ae

Browse files
committed
fix: πŸ› Handle elements implicitly inserted
1 parent 4324471 commit ed568ae

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-web-visual-editor",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"displayName": "Web Visual Editor",
55
"description": "Edit HTML files visually.",
66
"categories": [

β€Žsrc/visualEditor.tsβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ export class VisualEditorProvider implements vscode.CustomTextEditorProvider {
290290
document.querySelectorAll('body *, body').forEach(el => {
291291
// Add source code location information to all elements in body
292292
const location = dom.nodeLocation(el);
293-
if (!location) { throw Error(`Failed to get nodeLocation of element ${el}`); }
293+
if (!location) {
294+
// NOTE `location` can be null if the element is implicitly inserted
295+
// according to the HTML specification (e.g., `table > tbody`).
296+
return;
297+
}
294298
el.setAttribute('data-wve-code-start', location.startOffset.toString());
295299
el.setAttribute('data-wve-code-end', location.endOffset.toString());
296300
});

0 commit comments

Comments
Β (0)