kutlugsahin / smooth-dnd

drag and drop library for javascript
MIT License
615 stars 148 forks source link

constructor.prototype.matches also initiated for #document #57

Open NiekvR opened 5 years ago

NiekvR commented 5 years ago

We are using ngx-smooth-dnd in our project and are running into a problem with the dependency on this library. Since this library uses a polyfill to set the constructor.prototype.matches clashes with jQuery's closest method (https://api.jquery.com/closest/). Once it reaches the #document element it tries to see if it has el.matches initiated it returns true, but the tries to perform el.matches('selector). Since matches does not work on Nodes this gives the following error: Uncaught TypeError: Cannot read property 'querySelectorAll' of null.

In our opinion this problem is easily resolved by removing Node from the constructor.prototype.matches polyfill:

(function (constructor: any) { if (constructor && constructor.prototype && !constructor.prototype.matches) { constructor.prototype.matches = constructor.prototype.matchesSelector || constructor.prototype.mozMatchesSelector || constructor.prototype.msMatchesSelector || constructor.prototype.oMatchesSelector || constructor.prototype.webkitMatchesSelector || function (s: string) { var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length; while (--i >= 0 && matches.item(i) !== this) { } return i > -1; }; } })(Node || Element);

as is already suggested in: https://github.com/kutlugsahin/smooth-dnd/pull/29

We are really enthousiastic about the library and we hope you can fix this for us!

silvan88 commented 5 years ago

+1

I'm running into the same problems, can this please be merged asap?

ptrd commented 5 years ago

+1

NiekvR commented 5 years ago

Any idea on the status?

silvan88 commented 5 years ago

@kutlugsahin can you give an update? Else I need to look for other options...