swiftype-autocomplete-jquery icon indicating copy to clipboard operation
swiftype-autocomplete-jquery copied to clipboard

Remove Deprecations for jQuery 3.5

Open DenisLabrecque opened this issue 5 years ago • 2 comments

Using jQuery migrate 3.3 and jQuery 3.5 shows the following deprecations:

JQMIGRATE: Use of number-typed values is deprecated in jQuery.fn.css JQMIGRATE: jQuery.fn.resize() event shorthand is deprecated

This is related to adding styles to $.css() that don't have a unit after the width or height (CSS requires defined units, which can be in %, em, px, vw, vh, etc.)

There may be other issues as well, but this is the one currently highlighted on our site.

DenisLabrecque avatar Jun 26 '20 14:06 DenisLabrecque

Here is the corrected bit for number-typed values:

  var defaultDropdownStylesFunction = function($this) {
    var config = $this.data('swiftype-config-autocomplete');
    var $attachEl = config.attachTo ? $(config.attachTo) : $this;
    var offset = $attachEl.offset();
    var styles = {
      'position': 'absolute',
      'z-index': '9999',
      'top': offset.top + $attachEl.outerHeight() + 1 + 'px',
      'left': offset.left + 'px'
    };
    if (config.setWidth) {
      styles['width'] = $attachEl.outerWidth() - 2 + 'px';
    }
    return styles;
  };

DenisLabrecque avatar Jun 26 '20 15:06 DenisLabrecque

Hey Denis. Thanks for opening an issue and suggesting a fix.

Given that more and more people are moving away from jQuery, we're working on a replacement for this plugin. Meanwhile, we are limiting the scope of support for this plugin to critical bug fixes and security fixes.

I'll leave the issue open for some time so other users could copy your solution to fix the warnings.

yakhinvadim avatar Jun 26 '20 19:06 yakhinvadim