8000 fix: allow numbers in attribute values by tomi-bigpi · Pull Request #681 · yjs/yjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: allow numbers in attribute values #681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomi-bigpi
Copy link
@tomi-bigpi tomi-bigpi commented Dec 16, 2024

Changes YXMLElement to allow numbers in attribute values

This seems like a common use case when working with YJS and Prosemirror/TipTap schemas, since anything from list values, indent values, to heading levels will contain numeric values instead of strings when converting between YJS and Prosemirror.

fixes #680

@hoangqwe159
Copy link
Contributor

I do not think it is a good idea. It does not matter what value you get from Prosemirror or any editor, Yjs provides shared types and they should follow web standards. According to Web API, XML attribute values must always be quoted. That is why it should be always a string.

@tomi-bigpi
Copy link
Author

Well, MDN states for setAttribute that Value: A string containing the value to assign to the attribute. Any non-string value specified is converted automatically into a string. https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute That change is in the toDOM method (though only for number).

Additionally, note that this case came up in the first place because we're cloning an existing element which already had somehow managed have a number as the value type. So one could just as easily argue that things should have already broken upstream when the doc/elements were created. At a minimum, there's a big difference in the behavior between creating elements and cloning them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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