Skip to content

[BUG] BAD isEqual implementation #1830

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

Closed
bno1 opened this issue Sep 11, 2021 · 1 comment · Fixed by #1831
Closed

[BUG] BAD isEqual implementation #1830

bno1 opened this issue Sep 11, 2021 · 1 comment · Fixed by #1831

Comments

@bno1
Copy link
Contributor

bno1 commented Sep 11, 2021

🐛 Bug Report

The implementation of isEqual is bad. It only looks at keys of a and ignores the keys of b.

Lib version: 4.3.0

Steps To Reproduce

I was exporting an xlsx and I noticed that a column was interpreting numbers as dates. I discovered that the toModel method in column.js merges the column with the previous column because the column has an empty style. This causes column.equivalentTo(col) to return true at this line: https://github.com/exceljs/exceljs/blob/master/lib/doc/column.js#L275.

The check boils down to: _.isEqual(this.style, other.style). In my case, this.style is empty, so it can be written as: _.isEqual({}, {...}). isEqual will enumerate the keys of the first argument, which is empty, so it doesn't actually check any key.

Possible solution (optional, but very helpful):

Check that the keys match before iterating on a.

@bno1
Copy link
Contributor Author

bno1 commented Sep 11, 2021

Also, I don't get why you got rid of lodash. You still depend on it indirectly:

$ yarn why lodash.isequal
yarn why v1.22.11
[1/4] Why do we have the module "lodash.isequal"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "lodash.isequal@4.5.0"
info Reasons this module exists
   - "exceljs#fast-csv#@fast-csv#format" depends on it
   - Hoisted from "exceljs#fast-csv#@fast-csv#format#lodash.isequal"
info Disk size without dependencies: "64KB"
info Disk size with unique dependencies: "64KB"
info Disk size with transitive dependencies: "64KB"
info Number of shared dependencies: 0
Done in 0.09s.

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

Successfully merging a pull request may close this issue.

1 participant