kswedberg / jquery-expander

Expand and Collapse HTML content
https://kswedberg.github.io/jquery-expander/
Other
459 stars 168 forks source link

Jquery 3.5.1 Fixes #127

Closed Tuckmo closed 2 years ago

Tuckmo commented 4 years ago

Expander.js: Changed $.trim() to use String.prototype.trim as trim was deprecated by jQuery 3.5 and is the suggested update by jQuery.

Packages & Gruntfile changes: String.prototype.trim was not defined until updated to use esversion: 6. Verbose option removed due to no longer being supported. Semi-colons added to satisfy jshint.

Built & tested, all tests have passed.

kswedberg commented 4 years ago

Thanks a lot for the PR! Because this is such an old plugin and it's probably being used alongside really old versions of jQuery as well in some cases, I'd prefer to keep it working for stone-age browsers. I think it's a great idea to remove the $.trim(), but maybe it would make sense to just replace it with a regex replace. So, for example, we could add a line around line 115 for var rTrim = /(?:^\s+|\s+$)/g. Then, for example, instead of this:

return opts.normalizeWhitespace ? $.trim(str || '').replace(rMultiSpace, ' ') : str;

we could do this:

return opts.normalizeWhitespace ? (str || '').replace(rTrim, '').replace(rMultiSpace, ' ') : str;

That way, too, there would be no need to add esversion: 6 to the gruntfile.

Thoughts?

kswedberg commented 2 years ago

Removed $.trim() and used a regular expression instead to remove leading and trailing white space