Explorar el Código

Move decodeHTMLEntities util into headless

ubermanu hace 4 años
padre
commit
2f7dcb6bbc
Se han modificado 3 ficheros con 13 adiciones y 13 borrados
  1. 1 1
      src/headless/shared/parsers.js
  2. 12 0
      src/headless/shared/utils.js
  3. 0 12
      src/shared/utils.js

+ 1 - 1
src/headless/shared/parsers.js

@@ -2,7 +2,7 @@ import dayjs from 'dayjs';
 import sizzle from 'sizzle';
 import { Strophe } from 'strophe.js/src/strophe';
 import { _converse, api } from '@converse/headless/core';
-import { decodeHTMLEntities } from 'shared/utils';
+import { decodeHTMLEntities } from '@converse/headless/shared/utils';
 import { rejectMessage } from '@converse/headless/shared/actions';
 
 const { NS } = Strophe;

+ 12 - 0
src/headless/shared/utils.js

@@ -2,6 +2,7 @@ import Storage from '@converse/skeletor/src/storage.js';
 import log from '@converse/headless/log';
 import { _converse, api } from '@converse/headless/core';
 import { getOpenPromise } from '@converse/openpromise';
+import xss from 'xss/dist/xss';
 
 export function getDefaultStore () {
     if (_converse.config.get('trusted')) {
@@ -45,3 +46,14 @@ export function replacePromise (name) {
         log.debug(`Not replacing promise "${name}"`);
     }
 }
+
+const element = document.createElement('div');
+
+export function decodeHTMLEntities (str) {
+    if (str && typeof str === 'string') {
+        element.innerHTML = xss.filterXSS(str);
+        str = element.textContent;
+        element.textContent = '';
+    }
+    return str;
+}

+ 0 - 12
src/shared/utils.js

@@ -1,12 +0,0 @@
-import xss from 'xss/dist/xss';
-
-const element = document.createElement('div');
-
-export function decodeHTMLEntities (str) {
-    if (str && typeof str === 'string') {
-        element.innerHTML = xss.filterXSS(str);
-        str = element.textContent;
-        element.textContent = '';
-    }
-    return str;
-}