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

Object with prototype of `null` cannot be displayed using text interpolation #11241

Open
hezedu opened this issue Mar 25, 2020 · 1 comment
Open
Labels

Comments

@hezedu
Copy link

@hezedu hezedu commented Mar 25, 2020

Version

2.6.11

Reproduction link

https://codepen.io/hezedu/pen/GRJYXGR

Steps to reproduce

vue: 2.6.11

vue/dist/vue.runtime.js

Lines 96 to 102 in a59e05c

function toString (val) {
return val == null
? ''
: Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
? JSON.stringify(val, null, 2)
: String(val)
}

toString(Object.create(null);

Will crash:
TypeError: Cannot convert object to primitive value

What is expected?

TypeError

What is actually happening?

error

@posva posva added the improvement label Mar 25, 2020
@posva posva changed the title TypeError: Cannot convert object to primitive value Object with prototype of `null` cannot be displayed using text interpolation Mar 25, 2020
@sirlancelot

This comment has been minimized.

Copy link
Contributor

@sirlancelot sirlancelot commented Mar 25, 2020

What is the expectation here? Do you want it throw a certain kind of error? It is currently throwing TypeError which I feel is the most accurate. If a value doesn't contain the default toString property, it can't be trusted to output anything useful or more importantly, safe.

image

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.