Skip to content

Commit 126a473

Browse files
committed
0.0.4 - better error handling
1 parent e987ab0 commit 126a473

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ create_dom_diff = async (html) => {
4545

4646
let new_tree = parser.parse(new_html, tree_copy)
4747

48+
if (hasErrorNode(new_tree.rootNode)) return []
49+
4850
let diff = get_tree_diff(tree, tree_copy, new_tree, html, new_html)
4951

5052
html = new_html
@@ -251,6 +253,12 @@ create_dom_diff = async (html) => {
251253

252254
return [prefixLength, oldSuffixStart, newSuffixStart]
253255
}
256+
257+
function hasErrorNode(node) {
258+
if (node.type === "ERROR") return true
259+
for (let i = 0; i < node.childCount; i++)
260+
if (hasErrorNode(node.child(i))) return true
261+
}
254262
}
255263

256264
apply_dom_diff = (dom, diff) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@braidjs/dom-diff",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "utilities for diffing html doms",
55
"author": "Braid Working Group",
66
"repository": "braid-org/dom-diff",

0 commit comments

Comments
 (0)