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