Skip to content
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

getItemValue's wrong logic if argument is zero #199

Closed
acentfrio opened this issue Sep 16, 2019 · 1 comment
Closed

getItemValue's wrong logic if argument is zero #199

acentfrio opened this issue Sep 16, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@acentfrio
Copy link

acentfrio commented Sep 16, 2019

Hello I probably encountered an issue with your getItemValue function:

    getItemValue (item) {
      if (!item) return null
      if (this.itemValue) return item[this.itemValue]
      if (isObject(item)) {
        const keys = Object.keys(item)
        if (keys.length === 1) {
          return item[keys[0]]
        }
        return item
      }
      return item
    },

the first line is prone to errors in case the "0" (zero) is passed. suggest to change this to lodash isNil check

@iliyaZelenko
Copy link
Owner

iliyaZelenko commented Sep 17, 2019

Hi, yes, it seems there is such a problem, but it can be circumvented if you use zero as a string.

I would not want to depend on any dependency, so I can write my own version. More than lodash's isNil, in fact, It’s the same as item == null. Since the specification clearly states that null is equal to itself and undefined and vice versa.

In the next version, I will fix this error. I hope it is not urgent that I fix it for you?

@iliyaZelenko iliyaZelenko added the enhancement New feature or request label Sep 17, 2019
@iliyaZelenko iliyaZelenko changed the title getItemValue getItemValue's wrong logic if argument is zero Sep 17, 2019
iliyaZelenko pushed a commit that referenced this issue Sep 18, 2019
# [3.0.0](v2.11.1...v3.0.0) (2019-09-18)

### Bug Fixes

* **getitemvalue:** improve comparison to null and undefined ([a53dfe4](a53dfe4)), closes [#199](#199)

### Features

* **build:** added rollup, postcss ([d901fd9](d901fd9))
* **classes:** iZ-select--with-value class if select has value ([c978a76](c978a76))
* **component:** different sizes ([1e498e5](1e498e5))
* **component:** improve the `inputStyles` logic and height style ([1aeb01d](1aeb01d))
* **plugin's options:** the text option to set custom no data text ([9698298](9698298))
* **props:** arrowsDisableInstantSelection prop ([59e9af4](59e9af4)), closes [#9](#9)
* **props:** discard the loadingIndicator prop ([0c18790](0c18790))
* **sizes:** changed the idea about different sizes ([1abdf8d](1abdf8d))

### BREAKING CHANGES

* **props:** this prop no longer exists
* **props:** previously there was the false vlue, which led to the immediate selection of a menu
item. I decided that this was not the best practice.
* **component:** the sizes are adjusted to fit the bootstrap styles perfectly, maybe they changed a
little
* **build:** new build system (styles separated)
rin4573281133639 added a commit to rin4573281133639/iliyaZelenko9 that referenced this issue Feb 5, 2022
# [3.0.0](iliyaZelenko/vue-cool-select@v2.11.1...v3.0.0) (2019-09-18)

### Bug Fixes

* **getitemvalue:** improve comparison to null and undefined ([a53dfe4](iliyaZelenko/vue-cool-select@a53dfe4)), closes [#199](iliyaZelenko/vue-cool-select#199)

### Features

* **build:** added rollup, postcss ([d901fd9](iliyaZelenko/vue-cool-select@d901fd9))
* **classes:** iZ-select--with-value class if select has value ([c978a76](iliyaZelenko/vue-cool-select@c978a76))
* **component:** different sizes ([1e498e5](iliyaZelenko/vue-cool-select@1e498e5))
* **component:** improve the `inputStyles` logic and height style ([1aeb01d](iliyaZelenko/vue-cool-select@1aeb01d))
* **plugin's options:** the text option to set custom no data text ([9698298](iliyaZelenko/vue-cool-select@9698298))
* **props:** arrowsDisableInstantSelection prop ([59e9af4](iliyaZelenko/vue-cool-select@59e9af4)), closes [#9](iliyaZelenko/vue-cool-select#9)
* **props:** discard the loadingIndicator prop ([0c18790](iliyaZelenko/vue-cool-select@0c18790))
* **sizes:** changed the idea about different sizes ([1abdf8d](iliyaZelenko/vue-cool-select@1abdf8d))

### BREAKING CHANGES

* **props:** this prop no longer exists
* **props:** previously there was the false vlue, which led to the immediate selection of a menu
item. I decided that this was not the best practice.
* **component:** the sizes are adjusted to fit the bootstrap styles perfectly, maybe they changed a
little
* **build:** new build system (styles separated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants