Skip to content

Non-Scalar default dangerous change: Fix for #1566 #1593

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
wants to merge 3 commits into from

Conversation

mjmahone
Copy link
Contributor

@mjmahone mjmahone commented Dec 1, 2018

@helloqiu identified in #1566 that our dangerous changes check was incorrectly saying any non-scalar default value was a dangerous change, even if the default value hadn't actually changed. This is because we need to check the default value change for deep equality, rather than just whether the objects are identical.

@mjmahone mjmahone added this to the v14.1.0 milestone Dec 1, 2018
!isChangeSafeForDefaultValue(oldDefaultValue[key], newDefaultValue[key])
) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjmahone According to current implementation adding properties to object is safe.
For example isChangeSafeForDefaultValue({}, {a: 1}) => true or isChangeSafeForDefaultValue({a: undefined}, {a: 1}) => true.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second this. Can we add a couple more testcases to make sure that check works correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be correct: adding a previously undefined value is OK, but removing a previously undefined value is not (recursively).

@IvanGoncharov
Copy link
Member

IvanGoncharov commented Dec 2, 2018

@mjmahone I think it's better to add isDeepEqual to jsutils folder.
We can use https://github.com/substack/node-deep-equal as the basis and remove support for all weird types (e.g. Buffer, arguments, etc.)

@mjmahone mjmahone removed this from the v14.1.0 milestone Jan 15, 2019
@mjmahone
Copy link
Contributor Author

This will not make it into 14.1 milestone: there's a little bit too much clean-up work required here. I'll try to fast-follow with a patch to get this included, but I don't want to hold up the 14.1 release on a bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants