Skip to content

Conversation

@collingo
Copy link
Contributor

@collingo collingo commented Feb 1, 2017

Type coercion means we cannot override options with null values (or any other falsy values for that matter). This adds undefined checks for target and className (which suited my requirements) and tests to cover these cases.

What do you think? Correct approach? Would other option values benefit from null values?

this.nl2br = opts.nl2br || defaults.nl2br;
this.tagName = opts.tagName || defaults.tagName;
this.target = opts.target || defaults.target;
this.target = opts.target !== undefined ? opts.target : defaults.target;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using hasOwnProperty instead of the !== undefined check?

e.g.,

this.target = opts.hasOwnProperty('target') ? opts.target : defaults.target;

@collingo
Copy link
Contributor Author

collingo commented Feb 1, 2017

Sounds fine to me. I'll update the PR

@nfrasser nfrasser merged commit 00ded78 into nfrasser:master Oct 2, 2017
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