tiptap
tiptap copied to clipboard
[Bug]: attrs json object in heading does not have Object prototype
Which packages did you experience the bug in?
tiptap-core
What Tiptap version are you using?
2.1.13
What’s the bug you are facing?
Looks like attrs
object (e.g. {level: 1}
in my case) does not have Object
as it's prototype
and as a result calling attrs.hasOwnProperty
will throw exception.
Can't you just do something like Object.prototype.hasOwnProperty(attrs, 'level') you may ask? No, I'm not the one who do it. I use a library rxdb and
I created an issue in their repo but I think this should be fixed on both sides. There could be many more such cases.
This issue is critical for my app so if they won't fix it it would be awesome if you will. Please help. Thank u!
https://github.com/pubkey/rxdb/issues/5382
What browser are you using?
Chrome
Code example
No response
What did you expect to happen?
I expect call to hasOwnProperty do not throw
Anything to add? (optional)
No response
Did you update your dependencies?
- [X] Yes, I’ve updated my dependencies to use the latest version of all packages.
Are you sponsoring us?
- [ ] Yes, I’m a sponsor. 💖
Also hit attrs not having a prototype, it breaks serialization of docs in my project.
This is causing issues with next.js/react server actions as well. Next.js uses getPrototypeOf
when resolving a JSON payload and missing Object prototype is causing exceptions.
Are you saying that this.editor.getJSON()
does not actually return JSON? i.e. it is creating objects with a null prototype?
How are you accessing this values?
Are you saying that
this.editor.getJSON()
does not actually return JSON? i.e. it is creating objects with a null prototype?How are you accessing this values?
I am using getJSON()
. Yes, it seems like attrs
object for headings is created with a null
prototype.
I am using
getJSON()
. Yes, it seems likeattrs
object for headings is created with anull
prototype.
Ah okay, well this is because you are calling prosemirror's API for this. This is not an issue with tiptap per se but the underlying library. Honestly I would just JSON.parse(JSON.stringify(attrs.getJSON()))
which should give you a straight json object