Skip to content

[BUG] BAD isEqual implementation #1830

Closed
@bno1

Description

@bno1

🐛 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions