diff --git a/package-lock.json b/package-lock.json index 321cb716..3ca35aaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1108,6 +1108,12 @@ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "optional": true + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -8760,6 +8766,21 @@ "mkdirp": "^0.5.1" } }, + "ws": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.0.0.tgz", + "integrity": "sha512-cknCal4k0EAOrh1SHHPPWWh4qm93g1IuGGGwBjWkXmCG7LsDtL8w9w+YVfaF+KSVwiHQKDIMsSLBVftKf9d1pg==", + "optional": true, + "requires": { + "async-limiter": "^1.0.0" + } + }, + "xmldom": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz", + "integrity": "sha1-1QH5ezvbQDr4757MIFcxh6rawOk=", + "optional": true + }, "xvfb": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/xvfb/-/xvfb-0.2.3.tgz", diff --git a/package.json b/package.json index b9609d66..6ff333a4 100644 --- a/package.json +++ b/package.json @@ -73,5 +73,9 @@ "sinon-qunit": "~2.0.0", "yarpm": "^0.2.1" }, - "dependencies": {} + "dependencies": {}, + "optionalDependencies": { + "ws": "^7.0.0", + "xmldom": "^0.1.27" + } } diff --git a/src/bosh.js b/src/bosh.js index 95a1c0ec..1d32e883 100644 --- a/src/bosh.js +++ b/src/bosh.js @@ -8,6 +8,7 @@ /* global window, setTimeout, clearTimeout, XMLHttpRequest, ActiveXObject */ import core from './core'; +import { DOMParser } from './shims' const Strophe = core.Strophe; const $build = core.$build; diff --git a/src/core.js b/src/core.js index 93154162..be844d01 100644 --- a/src/core.js +++ b/src/core.js @@ -9,6 +9,7 @@ import MD5 from './md5'; import SHA1 from './sha1'; import utils from './utils'; +import * as shims from './shims'; /** Function: $build * Create a Strophe.Builder. @@ -330,26 +331,6 @@ const Strophe = { */ _xmlGenerator: null, - /** PrivateFunction: _makeGenerator - * _Private_ function that creates a dummy XML DOM document to serve as - * an element and text node generator. - */ - _makeGenerator: function () { - let doc; - // IE9 does implement createDocument(); however, using it will cause the browser to leak memory on page unload. - // Here, we test for presence of createDocument() plus IE's proprietary documentMode attribute, which would be - // less than 10 in the case of IE9 and below. - if (document.implementation.createDocument === undefined || - document.implementation.createDocument && document.documentMode && document.documentMode < 10) { - doc = this._getIEXmlDom(); - doc.appendChild(doc.createElement('strophe')); - } else { - doc = document.implementation - .createDocument('jabber:client', 'strophe', null); - } - return doc; - }, - /** Function: xmlGenerator * Get the DOM document to generate elements. * @@ -358,45 +339,11 @@ const Strophe = { */ xmlGenerator: function () { if (!Strophe._xmlGenerator) { - Strophe._xmlGenerator = Strophe._makeGenerator(); + Strophe._xmlGenerator = shims.getDummyXMLDOMDocument() } return Strophe._xmlGenerator; }, - /** PrivateFunction: _getIEXmlDom - * Gets IE xml doc object - * - * Returns: - * A Microsoft XML DOM Object - * See Also: - * http://msdn.microsoft.com/en-us/library/ms757837%28VS.85%29.aspx - */ - _getIEXmlDom : function() { - let doc = null; - const docStrings = [ - "Msxml2.DOMDocument.6.0", - "Msxml2.DOMDocument.5.0", - "Msxml2.DOMDocument.4.0", - "MSXML2.DOMDocument.3.0", - "MSXML2.DOMDocument", - "MSXML.DOMDocument", - "Microsoft.XMLDOM" - ]; - - for (let d=0; d