From 9161a9682c632ec9999e181a11ecc8eb756f4860 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 10 Jun 2025 03:10:32 +0200 Subject: [PATCH] [delta] useAttributes doesn't clean up empty objects --- src/types/YText.js | 1 + src/utils/AttributionManager.js | 4 +++- src/utils/Delta.js | 4 ++-- src/utils/RelativePosition.js | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/types/YText.js b/src/types/YText.js index 7bde7754..25eadf4c 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -1081,6 +1081,7 @@ export class YText extends AbstractType { */ const formattingAttribution = object.assign({}, d.usedAttribution) const attributesChanged = /** @type {{ [key: string]: Array }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {})) + debugger if (value === null) { delete attributesChanged[key] } else { diff --git a/src/utils/AttributionManager.js b/src/utils/AttributionManager.js index 6bb0af78..0f333e83 100644 --- a/src/utils/AttributionManager.js +++ b/src/utils/AttributionManager.js @@ -56,7 +56,9 @@ import * as encoding from 'lib0/encoding' * @return {Attribution?} */ export const createAttributionFromAttributionItems = (attrs, deleted) => { - if (attrs == null) return null + if (attrs == null) { + return null + } /** * @type {Attribution} */ diff --git a/src/utils/Delta.js b/src/utils/Delta.js index 5352bac1..d5fc0dd1 100644 --- a/src/utils/Delta.js +++ b/src/utils/Delta.js @@ -300,7 +300,7 @@ export class DeltaBuilder extends AbstractDelta { * @return {this} */ useAttributes (attributes) { - this.usedAttributes = object.isEmpty(attributes) ? null : object.assign({}, attributes) + this.usedAttributes = attributes return this } @@ -345,7 +345,7 @@ export class DeltaBuilder extends AbstractDelta { * @param {Attribution?} attribution */ useAttribution (attribution) { - this.usedAttribution = object.isEmpty(attribution) ? null : object.assign({}, attribution) + this.usedAttribution = attribution return this } diff --git a/src/utils/RelativePosition.js b/src/utils/RelativePosition.js index a3ec3fdf..ddee880c 100644 --- a/src/utils/RelativePosition.js +++ b/src/utils/RelativePosition.js @@ -72,7 +72,6 @@ export class RelativePosition { * @type {number} */ this.assoc = assoc - this.item && console.log('created relpos', this.item) // @todo remove } }