Commit 9c024757 authored by JC Brand's avatar JC Brand

Bugfix: `TypeError: o.getAttribute is not a function converse-chatview.js`

can cause messages to not appear.

* Check against null not Element.
* Avoid iterating over non-Element nodes
parent 3faaf6a6
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
- Reconnect if the server doesn't respond to a `ping` within 10 seconds. - Reconnect if the server doesn't respond to a `ping` within 10 seconds.
- Don't query for MAM MUC messages before the cached messages have been restored (another cause of duplicate messages). - Don't query for MAM MUC messages before the cached messages have been restored (another cause of duplicate messages).
- Show an error message and option to retry when fetching of the MAM archive times out - Show an error message and option to retry when fetching of the MAM archive times out
- Bugfix: `TypeError: o.getAttribute is not a function converse-chatview.js` (can cause messages to not appear).
## 5.0.0 (2019-08-08) ## 5.0.0 (2019-08-08)
......
...@@ -223,7 +223,7 @@ u.calculateElementHeight = function (el) { ...@@ -223,7 +223,7 @@ u.calculateElementHeight = function (el) {
u.getNextElement = function (el, selector='*') { u.getNextElement = function (el, selector='*') {
let next_el = el.nextElementSibling; let next_el = el.nextElementSibling;
while ((next_el instanceof Element) && !sizzle.matchesSelector(next_el, selector)) { while (next_el !== null && !sizzle.matchesSelector(next_el, selector)) {
next_el = next_el.nextElementSibling; next_el = next_el.nextElementSibling;
} }
return next_el; return next_el;
...@@ -231,24 +231,24 @@ u.getNextElement = function (el, selector='*') { ...@@ -231,24 +231,24 @@ u.getNextElement = function (el, selector='*') {
u.getPreviousElement = function (el, selector='*') { u.getPreviousElement = function (el, selector='*') {
let prev_el = el.previousElementSibling; let prev_el = el.previousElementSibling;
while ((prev_el instanceof Element) && !sizzle.matchesSelector(prev_el, selector)) { while (prev_el !== null && !sizzle.matchesSelector(prev_el, selector)) {
prev_el = prev_el.previousSibling prev_el = prev_el.previousElementSibling
} }
return prev_el; return prev_el;
} }
u.getFirstChildElement = function (el, selector='*') { u.getFirstChildElement = function (el, selector='*') {
let first_el = el.firstElementChild; let first_el = el.firstElementChild;
while ((first_el instanceof Element) && !sizzle.matchesSelector(first_el, selector)) { while (first_el !== null && !sizzle.matchesSelector(first_el, selector)) {
first_el = first_el.nextSibling first_el = first_el.nextElementSibling
} }
return first_el; return first_el;
} }
u.getLastChildElement = function (el, selector='*') { u.getLastChildElement = function (el, selector='*') {
let last_el = el.lastElementChild; let last_el = el.lastElementChild;
while ((last_el instanceof Element) && !sizzle.matchesSelector(last_el, selector)) { while (last_el !== null && !sizzle.matchesSelector(last_el, selector)) {
last_el = last_el.previousSibling last_el = last_el.previousElementSibling
} }
return last_el; return last_el;
} }
...@@ -284,7 +284,7 @@ u.hideElement = function (el) { ...@@ -284,7 +284,7 @@ u.hideElement = function (el) {
u.ancestor = function (el, selector) { u.ancestor = function (el, selector) {
let parent = el; let parent = el;
while ((parent instanceof Element) && !sizzle.matchesSelector(parent, selector)) { while (parent !== null && !sizzle.matchesSelector(parent, selector)) {
parent = parent.parentElement; parent = parent.parentElement;
} }
return parent; return parent;
...@@ -294,7 +294,7 @@ u.nextUntil = function (el, selector, include_self=false) { ...@@ -294,7 +294,7 @@ u.nextUntil = function (el, selector, include_self=false) {
/* Return the element's siblings until one matches the selector. */ /* Return the element's siblings until one matches the selector. */
const matches = []; const matches = [];
let sibling_el = el.nextElementSibling; let sibling_el = el.nextElementSibling;
while ((sibling_el instanceof Element) && !sibling_el.matches(selector)) { while (sibling_el !== null && !sibling_el.matches(selector)) {
matches.push(sibling_el); matches.push(sibling_el);
sibling_el = sibling_el.nextElementSibling; sibling_el = sibling_el.nextElementSibling;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment