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
Merged
Show file tree
Hide file tree
Changes from all commits
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.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.hasOwnProperty('className') ? 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;
});
});
});
});