From cdc7d3ffe6d2e3e35c10555f5326fcd770cb90fe Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Thu, 1 Apr 2021 14:54:37 -0500 Subject: [PATCH 1/2] fix crash when the walker didnt match because n will be null --- src/types/YXmlFragment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/YXmlFragment.js b/src/types/YXmlFragment.js index 1fd060b0..6fc0564e 100644 --- a/src/types/YXmlFragment.js +++ b/src/types/YXmlFragment.js @@ -83,7 +83,7 @@ export class YXmlTreeWalker { * @type {Item|null} */ let n = this._currentNode - let type = /** @type {any} */ (n.content).type + let type = /** @type {any} */ n && n.content && (n.content).type if (n !== null && (!this._firstCall || n.deleted || !this._filter(type))) { // if first call, we check if we can use the first item do { type = /** @type {any} */ (n.content).type From 249c4f9c459956f75b8534a5ec0a78c2f6d9fdbf Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Thu, 1 Apr 2021 14:59:34 -0500 Subject: [PATCH 2/2] switch order for type to get picked up --- src/types/YXmlFragment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/YXmlFragment.js b/src/types/YXmlFragment.js index 6fc0564e..6aa78bcd 100644 --- a/src/types/YXmlFragment.js +++ b/src/types/YXmlFragment.js @@ -83,7 +83,7 @@ export class YXmlTreeWalker { * @type {Item|null} */ let n = this._currentNode - let type = /** @type {any} */ n && n.content && (n.content).type + let type = n && n.content && /** @type {any} */ (n.content).type if (n !== null && (!this._firstCall || n.deleted || !this._filter(type))) { // if first call, we check if we can use the first item do { type = /** @type {any} */ (n.content).type