linkifyjs icon indicating copy to clipboard operation
linkifyjs copied to clipboard

Allow disabling linkClass

Open moll opened this issue 10 years ago • 6 comments

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!

moll avatar Jun 25 '16 08:06 moll

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.

moll avatar Aug 16 '16 09:08 moll

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 avatar Aug 17 '16 02:08 nfrasser

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.

nfrasser avatar Aug 17 '16 02:08 nfrasser

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. ;)

moll avatar Aug 17 '16 06:08 moll

+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 :)

jacobmumm avatar Aug 31 '16 16:08 jacobmumm

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

nfrasser avatar Mar 03 '18 21:03 nfrasser