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 disabling linkClass #144

Closed
moll opened this issue Jun 25, 2016 · 6 comments · Fixed by #154
Closed

Allow disabling linkClass #144

moll opened this issue Jun 25, 2016 · 6 comments · Fixed by #154

Comments

@moll
Copy link

moll commented Jun 25, 2016

Hey,

Given the falsy, as opposed to an undefined, check of linkClass: opts.linkClass || 'linkified' (https://github.com/SoapBox/linkifyjs/blob/master/src/linkify/utils/options.js#L25) it's not possible to disable the class entirely. One would have to resort to using " " to trick the coercive ||. Please consider using === undefined to allow removing the class without unintuitive hacks.

Thanks!

nfrasser added a commit that referenced this issue Aug 15, 2016
Features

* Added ability to override default options via linkify.options.defaults
* Options that take functions with value and type arguments can now be
  specified as objects, where each key is the target type. For example:

```
'github.com is #rad, please email nick@example.com'.linkify({
    formatHref: {
        email: (mailto) => `${mailto}?subject=Hello`,
        hashtag: (hashtag) => `https://twitter.com/hashtag/${hashtag.substr(1)}`
    }
});
```

Bug fixes

* Allow disabling linkClass (by using default options) - Fixes #144

Deprecations

* Deprecated `linkClass` option. Use `className` instead
* Deprecated `linkAttributes` option. Use `attributes` instead.
* The `linkified` default class name for links will no longer be provided in a
  future release

Breaking Changes

* Fully removed deprecated `newLine` option
nfrasser added a commit that referenced this issue Aug 16, 2016
* Enhancements and deprecations for options hash

Features

* Added ability to override default options via linkify.options.defaults
* Options that take functions with value and type arguments can now be
  specified as objects, where each key is the target type. For example:

```
'github.com is #rad, please email nick@example.com'.linkify({
    formatHref: {
        email: (mailto) => `${mailto}?subject=Hello`,
        hashtag: (hashtag) => `https://twitter.com/hashtag/${hashtag.substr(1)}`
    }
});
```

Bug fixes

* Allow disabling linkClass (by using default options) - Fixes #144

Deprecations

* Deprecated `linkClass` option. Use `className` instead
* Deprecated `linkAttributes` option. Use `attributes` instead.
* The `linkified` default class name for links will no longer be provided in a
  future release

Breaking Changes

* Fully removed deprecated `newLine` option

* Unit tests for linkify options utilities

Including improvements and fixes for QUnit tests

* Additional refactorings and updates to get IE to work

Note to self: IE8 is the devil
@moll
Copy link
Author

moll commented Aug 16, 2016

Please provide a way to disable it without modifying the defaults. Global variables like these are an awful solution, especially because they change behavior for other users of linkify in the same app.

@nfrasser nfrasser reopened this Aug 17, 2016
@nfrasser
Copy link
Collaborator

The goal of the defaults override was to provide a way to keep linkify's behaviour consistent between multiple calls to the plugin. e.g., not having to specify the same formatting functions every time you call linkify in your app code. It just happened to solve your problem, and admittedly not in the best way. I'll do a proper job of it in the next fix 😛

@nfrasser
Copy link
Collaborator

Also FYI: The default .linkified class was a carryover from a previous version of this library and is marked as deprecated in the upcoming 2.1 release. We're getting rid of it completely in a future 2.x or 3.x release.

@moll
Copy link
Author

moll commented Aug 17, 2016

Thanks.

As with globals, I'd disallow modifying defaults in any sane code base as that breaks second or third party code that happens to also depend on linkify. Most package managers, like NPM, share instances of compatible dependencies and changing defaults under other code is a recipe for disaster. ;)

@jacobmumm
Copy link

+1 Have no need to add a class. Switching from angular's linkyFilter to this broke our unit tests with the addition of the linkified class. I guess I'll just expect it to be there for now and remove later. Great looking product, though. Thanks :)

@nfrasser
Copy link
Collaborator

nfrasser commented Mar 3, 2018

Fixed in v2.1.6. Specify className: null in the options. 3.0 will remove the default linkified class.

@nfrasser nfrasser closed this as completed Mar 3, 2018
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 a pull request may close this issue.

3 participants