-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #779 from cibernox/is-equal
[FEATURE] If options implement the `isEqual` method, EPS will use it
- Loading branch information
Showing
7 changed files
with
255 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
import Ember from 'ember'; | ||
import { helper } from 'ember-helper'; | ||
import { isEmberArray } from 'ember-array/utils'; | ||
|
||
const { isEqual } = Ember; | ||
|
||
// TODO: Make it private or scoped to the component | ||
export function emberPowerSelectIsSelected([option, selected]/* , hash*/) { | ||
return isEmberArray(selected) ? selected.indexOf(option) > -1 : option === selected; | ||
if (selected === undefined || selected === null) { | ||
return false; | ||
} | ||
if (isEmberArray(selected)) { | ||
for (let i = 0; i < selected.length; i++) { | ||
if (isEqual(selected[i], option)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} else { | ||
return isEqual(option, selected); | ||
} | ||
} | ||
|
||
export default helper(emberPowerSelectIsSelected); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.