DeuxHuitHuit / quicksearch

A jQuery plugin for searching through DOM Elements quickly
https://www.npmjs.org/package/jquery.quicksearch
Other
135 stars 35 forks source link

Uncaught TypeError: global.clearTimeout is not a function #36

Closed FDiskas closed 7 years ago

FDiskas commented 8 years ago

Im using latest

jQuery-QuickSearch - v2.3.1

I installed this plugin via NPM and included it using es6

FDiskas commented 8 years ago

:inbox_tray: You should probably use this: https://toddmotto.com/what-function-window-document-undefined-iife-really-means/#non-browser-global-environments

nitriques commented 8 years ago

@FDiskas This is exactly what I've done: https://github.com/DeuxHuitHuit/quicksearch/blob/f3fdd0d3849110043981c0b7b157da52f1912a60/src/jquery.quicksearch.js#L334 use this has the global env.

Also, the 'global' keyword is nowhere to be found in 'dist/jquery.quicksearch.min.js', which is the "main" file in package.json... Maybe the code is not es6 ready.... Can you check what the "this" keywords refers to ?

reganjohnson commented 7 years ago

Having the same issue, compiled using webpack.

require('jquery.quicksearch');

jquery.quicksearch.min.js?9531:6 Uncaught TypeError: b.clearTimeout is not a function(…)

@FDiskas were you able to find a solution?

reganjohnson commented 7 years ago

I was able to get a quick fix by editing jquery.quicksearch.min.js and changing !function(a,b,c){}(jQuery,this); to !function(a,b,c){}(jQuery,window);

Perhaps I may have some configuration issue with how everything is being compiled? Any advice @nitriques?

nitriques commented 7 years ago

Any advice @nitriques?

I clearly do not understand what's going on. window does not exists in node... I'll try to check this tonite.

FDiskas commented 7 years ago

@reganjohnson first i did a fork then for some time i used the fork. Now I just removed this dependency

nitriques commented 7 years ago

@FDiskas I am still open to a valid fix.

FDiskas commented 7 years ago

Working solution for me was this https://github.com/DeuxHuitHuit/quicksearch/pull/33/files

FDiskas commented 7 years ago

Check the last file changes src/jquery.quicksearch.js

nitriques commented 7 years ago

@FDiskas Are you using webpack as well ?

nitriques commented 7 years ago

I would really like to fix this and here's what I do not understand.

  1. In node, global == this is true. It has setTimeout() and clearTimeout().
  2. In node, window == undefined.
  3. I do not see how this can works.

I am a complete webpack n00b. I forked the original project because it was and still is not maintained. I would really like to keep the original things working but still be able to make it work under webpack. Any help on that issue would be cool. Would the loader referenced earlier by @FDiskas works usign webpack ?

FDiskas commented 7 years ago

Yes webpack

On Fri, Nov 18, 2016, 3:40 AM Nicolas Brassard notifications@github.com wrote:

I would really like to fix this and here's what I do not understand.

  1. In node, global == this is true. It has setTimeout() and clearTimeout().
  2. In node, window == undefined.
  3. I do not see how this https://github.com/DeuxHuitHuit/quicksearch/blob/master/src/jquery.quicksearch.js#L330 can works.

I am a complete webpack n00b. I forked the original project because it was and still is not maintained. I would really like to keep the original things working but still be able to make it work under webpack. Any help on that issue would be cool. Would the loader referenced earlier by @FDiskas https://github.com/FDiskas works usign webpack ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DeuxHuitHuit/quicksearch/issues/36#issuecomment-261425100, or mute the thread https://github.com/notifications/unsubscribe-auth/AAckJlFTS-iJjTm0cAXZcZVq7jtjHR9Xks5q_QIIgaJpZM4KZgOy .

nitriques commented 7 years ago

Ok, that may be the root of the problem. I'll test it ASAP.

nitriques commented 7 years ago

@FDiskas @patrocle @reganjohnson I've publish version 2.3.2 on npm, would you mind to test it ? It's still in the dev branch. Thanks.

patrocle commented 7 years ago

It works ! Thanks !

nitriques commented 7 years ago

Thanks @patrocle . It has been on npm for some time now and I've juste merged it into master.