[delta] useAttributes doesn't clean up empty objects

This commit is contained in:
Kevin Jahns
2025-06-10 03:10:32 +02:00
parent a9f802d77e
commit 9161a9682c
4 changed files with 6 additions and 4 deletions

View File

@@ -1081,6 +1081,7 @@ export class YText extends AbstractType {
*/ */
const formattingAttribution = object.assign({}, d.usedAttribution) const formattingAttribution = object.assign({}, d.usedAttribution)
const attributesChanged = /** @type {{ [key: string]: Array<any> }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {})) const attributesChanged = /** @type {{ [key: string]: Array<any> }} */ (formattingAttribution.attributes = object.assign({}, formattingAttribution.attributes ?? {}))
debugger
if (value === null) { if (value === null) {
delete attributesChanged[key] delete attributesChanged[key]
} else { } else {

View File

@@ -56,7 +56,9 @@ import * as encoding from 'lib0/encoding'
* @return {Attribution?} * @return {Attribution?}
*/ */
export const createAttributionFromAttributionItems = (attrs, deleted) => { export const createAttributionFromAttributionItems = (attrs, deleted) => {
if (attrs == null) return null if (attrs == null) {
return null
}
/** /**
* @type {Attribution} * @type {Attribution}
*/ */

View File

@@ -300,7 +300,7 @@ export class DeltaBuilder extends AbstractDelta {
* @return {this} * @return {this}
*/ */
useAttributes (attributes) { useAttributes (attributes) {
this.usedAttributes = object.isEmpty(attributes) ? null : object.assign({}, attributes) this.usedAttributes = attributes
return this return this
} }
@@ -345,7 +345,7 @@ export class DeltaBuilder extends AbstractDelta {
* @param {Attribution?} attribution * @param {Attribution?} attribution
*/ */
useAttribution (attribution) { useAttribution (attribution) {
this.usedAttribution = object.isEmpty(attribution) ? null : object.assign({}, attribution) this.usedAttribution = attribution
return this return this
} }

View File

@@ -72,7 +72,6 @@ export class RelativePosition {
* @type {number} * @type {number}
*/ */
this.assoc = assoc this.assoc = assoc
this.item && console.log('created relpos', this.item) // @todo remove
} }
} }