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

Allow null overrides in options for target and className #189

Merged
merged 2 commits into from
Oct 2, 2017

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?

@@ -23,13 +23,13 @@ function Options(opts) {
this.formatHref = opts.formatHref || defaults.formatHref;
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