Skip to content

Commit

Permalink
Prevent JSON parse error (#827)
Browse files Browse the repository at this point in the history
* Prevent JSON parse error

Users can pass in `{ enabled: true }` as the sortOptions, which means `initialSortBy` would be `undefined` and `JSON.parse` throws an error when you hand it `undefined`. So we need to default the value if it is not present.

* Update src/components/Table.vue
  • Loading branch information
TheJaredWilcurt authored Mar 11, 2021
1 parent 34e793b commit c26940a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ export default {
initializeSort() {
const { enabled, initialSortBy, multipleColumns } = this.sortOptions;
const initSortBy = JSON.parse(JSON.stringify(initialSortBy));
const initSortBy = JSON.parse(JSON.stringify(initialSortBy || {}));
if (typeof enabled === 'boolean') {
this.sortable = enabled;
Expand Down

0 comments on commit c26940a

Please sign in to comment.