fix(chat): polyfills for lib-jitsi-meet ChatRoom#onPresence (#2678)

The onPresence parsing was refactored to remove use of jQuery.
This exposed three methods not available in react-native:
ParentNode.children, ChildNode.remove, and
document.querySelectorAll. The querySelectorAll change could
be swapped for the already polyfilled querySelector, but
children and remove had to be added. The polyfills are based
on those supplied by MDN web docs, but modified to pass jitsi
linting.
This commit is contained in:
virtuacoplenny 2018-03-28 18:04:42 -07:00 committed by bbaldino
parent 8492aad7d6
commit 1e0a3ceb74
1 changed files with 37 additions and 0 deletions

View File

@ -195,6 +195,18 @@ function _visitNode(node, callback) {
};
}
// Element.remove
//
// Required by:
// - lib-jitsi-meet ChatRoom#onPresence parsing
if (typeof elementPrototype.remove === 'undefined') {
elementPrototype.remove = function() {
if (this.parentNode !== null) {
this.parentNode.removeChild(this);
}
};
}
// Element.innerHTML
//
// Required by:
@ -231,6 +243,31 @@ function _visitNode(node, callback) {
}
});
}
// Element.children
//
// Required by:
// - lib-jitsi-meet ChatRoom#onPresence parsing
if (!elementPrototype.hasOwnProperty('children')) {
Object.defineProperty(elementPrototype, 'children', {
get() {
const nodes = this.childNodes;
const children = [];
let i = 0;
let node = nodes[i];
while (node) {
if (node.nodeType === 1) {
children.push(node);
}
i += 1;
node = nodes[i];
}
return children;
}
});
}
}
// FIXME There is a weird infinite loop related to console.log and