From 13ad0c8464dd3886c8a66c5016d8398d2e3f40ba Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 27 Aug 2019 02:17:08 +0200 Subject: [PATCH] implement Y.XmlFragment.length --- src/types/YText.js | 2 +- src/types/YXmlFragment.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/types/YText.js b/src/types/YText.js index 167841b9..a2121a99 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -272,7 +272,7 @@ const formatText = (transaction, parent, left, right, currentAttributes, length, // iterate until first non-format or null is found // delete all formats with attributes[format.key] != null while (length > 0 && right !== null) { - if (right.deleted === false) { + if (!right.deleted) { switch (right.content.constructor) { case ContentFormat: const { key, value } = /** @type {ContentFormat} */ (right.content) diff --git a/src/types/YXmlFragment.js b/src/types/YXmlFragment.js index 62fa543e..247f4b1b 100644 --- a/src/types/YXmlFragment.js +++ b/src/types/YXmlFragment.js @@ -151,6 +151,10 @@ export class YXmlFragment extends AbstractType { return new YXmlFragment() } + get length () { + return this._prelimContent === null ? this._length : this._prelimContent.length + } + /** * Create a subtree of childNodes. *