Browse Source

Handle non-elements, like text nodes

JC Brand 6 years ago
parent
commit
94bcba741b
2 changed files with 5 additions and 3 deletions
  1. 2 1
      dist/converse.js
  2. 3 2
      src/headless/utils/core.js

+ 2 - 1
dist/converse.js

@@ -69716,7 +69716,8 @@ u.matchesSelector = function (el, selector) {
    *      (DOMElement) el - The DOM element
    *      (DOMElement) el - The DOM element
    *      (String) selector - The selector
    *      (String) selector - The selector
    */
    */
-  return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector);
+  const match = el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector;
+  return match ? match.call(el, selector) : false;
 };
 };
 
 
 u.queryChildren = function (el, selector) {
 u.queryChildren = function (el, selector) {

+ 3 - 2
src/headless/utils/core.js

@@ -179,14 +179,15 @@ u.matchesSelector = function (el, selector) {
      *      (DOMElement) el - The DOM element
      *      (DOMElement) el - The DOM element
      *      (String) selector - The selector
      *      (String) selector - The selector
      */
      */
-    return (
+    const match = (
         el.matches ||
         el.matches ||
         el.matchesSelector ||
         el.matchesSelector ||
         el.msMatchesSelector ||
         el.msMatchesSelector ||
         el.mozMatchesSelector ||
         el.mozMatchesSelector ||
         el.webkitMatchesSelector ||
         el.webkitMatchesSelector ||
         el.oMatchesSelector
         el.oMatchesSelector
-    ).call(el, selector);
+    );
+    return match ? match.call(el, selector) : false;
 };
 };
 
 
 u.queryChildren = function (el, selector) {
 u.queryChildren = function (el, selector) {