#680·yjs

YXmlElement.clone() only copies string attribute values / does not support numbers

Author: tomi-bigpiCreated Dec 16, 2024Updated Jun 8, 2026
Labelsbug

Describe the bug YXmlElement.clone() has a check on line 97 https://github.com/yjs/yjs/blob/main/src/types/YXmlElement.js#L97 to verify whether the attribute value is a string and skips the attribute if the value isn't a string. However, this seems to be the only place where this check is performed, which in turn means it is entirely possible to have nodes with numbers as values, but any cloned node will silently drop the attributes causing hard to find issues.

However, there are lots of use cases where the attribute value can be a number. The primary case we're running into is where a Prosemirror / YJS integration has paragraphs with indent values (and heading levels, table row/colspans, etc.) that are numbers.

To Reproduce Attempt to clone any YXmlElement that has non-string attribute values.

Expected behavior Attribute values that are numbers should be copied over to the clone and not dropped.

Environment Information YJS main / v13.6.20

UPDATE: Looks like the types for setAttribute are locked to a string as the only valid type, so that would need to be expanded to resolve the issue with clone.