google-pay / google-pay-button

Google Pay button - React, Angular, and custom element
Apache License 2.0
250 stars 60 forks source link

fix: invalidation values comparison for objects #239

Closed dmengelt closed 1 year ago

dmengelt commented 1 year ago

The check to determine if the client should be invalidated (and therefore the button is redrawn) is flaky for objects like allowedPaymentMethods. By using JSON.stringify(value) this change makes sure to compare strings. All unit tests validating this behaviour still pass.

This should also fix #228 as this.updateElement() will no longer be triggered in this case.

dmengelt commented 1 year ago

@socsieng does this make sense to you? 😉 Unfortunately there is no guarantee of order for a comparison with JSON.stringify but I think it is still better vs. the current solution.

dmengelt commented 1 year ago

@socsieng great thanks! yeah I had a quick look at deep-equal. For now I think we are ok.