Skip to content

Commit

Permalink
fix: allow an object's Symbols to be observed (#6704)
Browse files Browse the repository at this point in the history
Attempting to parseFloat on a Symbol throws the error
`Cannot convert a Symbol value to a string`.

A Symbol can be cast to a string using `.toString()` or `String()` though,
so explicitly casting before parsing resolves the issue, allowing `Vue.set` to
be called on Symbols.
  • Loading branch information
dak authored and yyx990803 committed Sep 28, 2017
1 parent 4361a2b commit 4fd2ce8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function isRegExp (v: any): boolean {
* Check if val is a valid array index.
*/
export function isValidArrayIndex (val: any): boolean {
const n = parseFloat(val)
const n = parseFloat(String(val))
return n >= 0 && Math.floor(n) === n && isFinite(val)
}

Expand Down

0 comments on commit 4fd2ce8

Please sign in to comment.