Files
vault/ui/lib/core/addon/helpers/loose-equal.js
claire bontempo e32cf520f4 UI: fixes pki role editing changing to default key parameter values (#20907)
* add integer-to-string helper

* rename and add test

* add role test

* finish tests

* pass options so values are only converted if the type matches

* okay lets hit it with the loose-equal instead

* add changelog
2023-05-31 15:44:22 -07:00

23 lines
614 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { helper } from '@ember/component/helper';
/*
* use sparingly *
ex: logic for an HTML element's selected boolean because <select> values are strings
strict equal (===) will fail if the API param is a number
<option selected={{loose-equal model.someAttr someOption)}} value={{someOption}}>
*/
export function looseEqual([a, b]) {
// loose equal 0 == '' returns true, we don't want that
if ((a === 0 && b === '') || (a === '' && b === 0)) {
return false;
}
return a == b;
}
export default helper(looseEqual);