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

A little confused with converting symbol to 'DOMString' #14

Closed
hikerpig opened this issue Mar 18, 2019 · 2 comments
Closed

A little confused with converting symbol to 'DOMString' #14

hikerpig opened this issue Mar 18, 2019 · 2 comments

Comments

@hikerpig
Copy link

When unit testing with jest I get a TypeError, so I dug into this line

    if (typeof V === "symbol") {
        throw new TypeError(_("is a symbol, which cannot be converted to a string", opts));
    }

In ecma-262 spec, there is Symbol.prototype.toString() method, it seems to me that convertion from Symbol to String should not raise a Error.

Would you be kind enough to explain this?

@domenic
Copy link
Member

domenic commented Mar 18, 2019

There are many ways to convert things to a string. However, the Web IDL spec, which this library implements, chooses one of them: https://heycam.github.io/webidl/#es-DOMString step 2. That should provide the answer.

@hikerpig
Copy link
Author

Thank you, I think maybe I should do a little patching an wrapping in my own code

cexbrayat added a commit to cexbrayat/vue-next that referenced this issue Nov 18, 2021
Currently, passing a `Symbol` to an attribute throws in `runtime-dom` with:

```
TypeError: Failed to execute 'setAttribute' on 'Element': parameter 2 is a symbol, which cannot be converted to a string.
```

This is because the underlying library used for conversion does not handle Symbol (see jsdom/webidl-conversions#14).

This issue cascades into VTU-next as `shallowMount` attempts to write props values as attributes.
See vuejs/test-utils#1076 for more context.
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

No branches or pull requests

2 participants