Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/linkify/utils/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

this.validate = opts.validate || defaults.validate;
this.ignoreTags = [];

// linkAttributes and linkClass is deprecated
this.attributes = opts.attributes || opts.linkAttributes || defaults.attributes;
this.className = opts.className || opts.linkClass || defaults.className;
this.className = opts.className !== undefined ? opts.className : (opts.linkClass || defaults.className);

// Make all tags names upper case

Expand Down
23 changes: 23 additions & 0 deletions test/spec/linkify/utils/options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,27 @@ describe('linkify/utils/options', () => {
});
});
});

describe('Nullifying Options', () => {
var opts;

beforeEach(() => {
opts = new Options({
target: null,
className: null
});
});

describe('target', () => {
it('should be nulled', () => {
expect(opts.target).to.be.null;
});
});

describe('className', () => {
it('should be nulled', () => {
expect(opts.className).to.be.null;
});
});
});
});