Skip to content

fix: Option usedefaults re-assign #11

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

olavocneto
Copy link

var options = {
  reverse: true,
  usedefaults: false
}
var formatter = new StringMask('+00 (00) 0000-0000', options)

Old code;

usedefaults: this.options.usedefaults || this.options.reverse

OR operator (||) returns the condition on the right side but the expected one was to have returned the left side.

OR for defaults can be convenient because it is short and easy to write but to booleans parameters it was not good.

```js
var options = {
  reverse: true,
  usedefaults: false
}
var formatter = new StringMask('+00 (00) 0000-0000')
```
Old code;

```js
usedefaults: this.options.usedefaults || this.options.reverse
```

OR operator (||) return false on left side and return true on right side.

OR for defaults can be convenient because it is short and easy to write but to booleans parameters it was not good.
@coveralls
Copy link

coveralls commented Mar 4, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 5cd69bb on financialsistemas:bug/options-default into 094cc31 on the-darc:master.

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

Successfully merging this pull request may close these issues.

2 participants