Skip to content

Commit

Permalink
fix(shims) correct @xmldom/xmldom require (#389)
Browse files Browse the repository at this point in the history
* fix(shims) correct @xmldom/xmldom require

* fix(shims) refer to @xmldom/xmldom
  • Loading branch information
NewEraCracker authored Jan 14, 2022
1 parent 9da72c0 commit 294cecf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/shims.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ export const WebSocket = getWebSocketImplementation()
* Used implementations:
* - supported browsers: built-in in DOMParser global
* https://developer.mozilla.org/en-US/docs/Web/API/DOMParser#Browser_compatibility
* - nodejs: use 'xmldom' module
* https://www.npmjs.com/package/xmldom
* - nodejs: use '@xmldom/xmldom' module
* https://www.npmjs.com/package/@xmldom/xmldom
*/
function getDOMParserImplementation () {
let DOMParserImplementation = global.DOMParser
if (typeof DOMParserImplementation === 'undefined') {
try {
DOMParserImplementation = require('xmldom').DOMParser;
DOMParserImplementation = require('@xmldom/xmldom').DOMParser;
} catch (err) {
throw new Error('You must install the "xmldom" package to use Strophe in nodejs.');
throw new Error('You must install the "@xmldom/xmldom" package to use Strophe in nodejs.');
}
}
return DOMParserImplementation
Expand Down Expand Up @@ -96,16 +96,16 @@ function _getIEXmlDom () {
* - IE < 10: avoid using createDocument() due to a memory leak, use ie-specific
* workaround
* - other supported browsers: use document's createDocument
* - nodejs: use 'xmldom'
* - nodejs: use '@xmldom/xmldom'
*/
export function getDummyXMLDOMDocument () {
// nodejs
if (typeof document === 'undefined') {
try {
const DOMImplementation = require('xmldom').DOMImplementation;
const DOMImplementation = require('@xmldom/xmldom').DOMImplementation;
return new DOMImplementation().createDocument('jabber:client', 'strophe', null);
} catch (err) {
throw new Error('You must install the "xmldom" package to use Strophe in nodejs.');
throw new Error('You must install the "@xmldom/xmldom" package to use Strophe in nodejs.');
}
}
// IE < 10
Expand Down

0 comments on commit 294cecf

Please sign in to comment.