Skip to content
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

TypeError when initialized with null content #325

Closed
raray opened this issue Feb 14, 2023 · 5 comments · Fixed by #327
Closed

TypeError when initialized with null content #325

raray opened this issue Feb 14, 2023 · 5 comments · Fixed by #327
Labels

Comments

@raray
Copy link

raray commented Feb 14, 2023

Version
1.1.0

Describe the bug
Mounting <QuillEditor> with null content causes the following error:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'slice')

This is a breaking changed introduced in #317 - https://github.com/vueup/vue-quill/pull/317/files#diff-0fe7a2c7e46d97a72a1fdc2df750c7b1a775050558328b4985c0095fef057cfaR189

typeof delta === 'object' is an insufficient check as null is also an object.

To Reproduce
Mount a QuillEditor component with null content:

<QuillEditor
    :content="null" 
/>

Expected behavior
The component can be mounted without error.

Browser (please complete the following information):
Arc Version 0.89.0 (37129)
Chromium Engine Version 110.0.5481.90

@Tofandel
Copy link
Contributor

Tofandel commented Feb 16, 2023

The content is assumed to not be null by the type definition, it's a bad idea to send a null value given a Delta or string is expected, usually with props you want to send undefined so that the default value is used instead

    content: {
      type: [String, Object] as PropType<string | Delta>,
      default: () => {},
    },

Other functions were not meant to handle null values as well like setContents

The fix is easy enough, I'll include a fix for the type definition with it

@luthfimasruri
Copy link
Collaborator

🎉 This issue has been resolved in version 1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@akin-oz
Copy link

akin-oz commented Mar 16, 2023

I started to get TypeError after this version. I think it's related to the default value of the content prop.
I recently updated my project to use the latest version, and I started to experience a TypeError in my console. I suspect that this error might be related to the default value of the content prop.

TypeError: delta.slice is not a function
The trace starts from maybeClone function.

@Tofandel
Copy link
Contributor

Tofandel commented Mar 16, 2023

Please provide a reproduction if you think you encountered a bug

Though the only way you'd get this error is if you passed an object that is not a delta to the content prop in delta mode, which is not a supported use case

@akin-oz
Copy link

akin-oz commented Mar 16, 2023

Please provide a reproduction if you think you encountered a bug

Though the only way you'd get this error is if you passed an object that is not a delta to the content prop in delta mode, which is not a supported use case

Thank you! The initial value of the content prop was an empty object. I had to do this because undefined wasn't supported but now it works!

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

Successfully merging a pull request may close this issue.

4 participants