Updates #1098 IE doesn't support document.contains

This commit is contained in:
JC Brand 2018-05-23 04:22:47 +02:00
parent 9500900f22
commit f0b1295577
3 changed files with 10 additions and 4 deletions

View File

@ -469,8 +469,7 @@
insertIntoControlBox () {
const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview) &&
!_converse.root.contains(this.el)) {
if (!_.isUndefined(controlboxview) && !u.rootContains(_converse.root, this.el)) {
const el = controlboxview.el.querySelector('.bookmarks-list');
if (!_.isNull(el)) {
el.parentNode.replaceChild(this.el, el);

View File

@ -181,8 +181,7 @@
insertIntoControlBox () {
const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview) &&
!_converse.root.contains(this.el)) {
if (!_.isUndefined(controlboxview) && !u.rootContains(_converse.root, this.el)) {
const el = controlboxview.el.querySelector('.open-rooms-list');
if (!_.isNull(el)) {
el.parentNode.replaceChild(this.el, el);

View File

@ -654,6 +654,14 @@
};
};
u.rootContains = function (root, el) {
// The document element does not have the contains method in IE.
if (root === document && !root.contains) {
return document.head.contains(el) || document.body.contains(el);
}
return root.contains ? root.contains(el) : window.HTMLElement.prototype.contains.call(root, el);
};
u.createFragmentFromText = function (markup) {
/* Returns a DocumentFragment containing DOM nodes based on the
* passed-in markup text.