From 23e15fd161f8e79f92c8c859e2ec811f1e1938ce Mon Sep 17 00:00:00 2001 From: djmaze Date: Thu, 25 Mar 2021 09:38:45 +0100 Subject: [PATCH] Use own createElement() instead of doc.createElement --- dev/App/Abstract.js | 3 ++- dev/Common/Translator.js | 4 ++-- dev/Common/Utils.js | 4 ++-- dev/Common/UtilsUser.js | 4 ++-- dev/Stores/User/Message.js | 4 ++-- dev/Stores/User/Pgp.js | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dev/App/Abstract.js b/dev/App/Abstract.js index 51fdf8ad3..1c19f9ba5 100644 --- a/dev/App/Abstract.js +++ b/dev/App/Abstract.js @@ -2,6 +2,7 @@ import ko from 'ko'; import { doc, + createElement, elementById, Settings } from 'Common/Globals'; @@ -39,7 +40,7 @@ export class AbstractApp { open(link, '_self'); focus(); } else { - const oLink = doc.createElement('a'); + const oLink = createElement('a'); oLink.href = link; doc.body.appendChild(oLink).click(); oLink.remove(); diff --git a/dev/Common/Translator.js b/dev/Common/Translator.js index aa47d5f25..552d16d15 100644 --- a/dev/Common/Translator.js +++ b/dev/Common/Translator.js @@ -1,7 +1,7 @@ import ko from 'ko'; import { Notification, UploadErrorCode } from 'Common/Enums'; import { langLink } from 'Common/Links'; -import { doc } from 'Common/Globals'; +import { doc, createElement } from 'Common/Globals'; let I18N_DATA = window.rainloopI18N || {}; @@ -122,7 +122,7 @@ export function getUploadErrorDescByCode(code) { */ export function reload(admin, language) { return new Promise((resolve, reject) => { - const script = doc.createElement('script'); + const script = createElement('script'); script.onload = () => { // reload the data if (window.rainloopI18N) { diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index cc5351d47..89b55658a 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -1,5 +1,5 @@ import { SaveSettingsStep } from 'Common/Enums'; -import { doc, elementById } from 'Common/Globals'; +import { doc, createElement, elementById } from 'Common/Globals'; export const isArray = Array.isArray, @@ -119,7 +119,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) { .then(data => { if (data && isArray(data) && 2 === data.length) { if (themeLink && !themeStyle) { - themeStyle = doc.createElement('style'); + themeStyle = createElement('style'); themeStyle.id = 'app-theme-style'; themeLink.after(themeStyle); themeLink.remove(); diff --git a/dev/Common/UtilsUser.js b/dev/Common/UtilsUser.js index 48493219a..93fed0663 100644 --- a/dev/Common/UtilsUser.js +++ b/dev/Common/UtilsUser.js @@ -2,7 +2,7 @@ import { ComposeType, FolderType } from 'Common/EnumsUser'; import { EmailModel } from 'Model/Email'; import { encodeHtml } from 'Common/Html'; import { isArray } from 'Common/Utils'; -import { doc } from 'Common/Globals'; +import { createElement } from 'Common/Globals'; /** * @param {(string|number)} value @@ -79,7 +79,7 @@ export function htmlToPlain(html) { }; const - tpl = doc.createElement('template'), + tpl = createElement('template'), convertPre = (...args) => args && 1 < args.length ? args[1] diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 12dcb26df..33fda90f1 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -2,7 +2,7 @@ import ko from 'ko'; import { Scope, Notification } from 'Common/Enums'; import { MessageSetAction } from 'Common/EnumsUser'; -import { doc, elementById } from 'Common/Globals'; +import { doc, createElement, elementById } from 'Common/Globals'; import { isNonEmptyArray, pInt, pString, addObservablesTo, addSubscribablesTo } from 'Common/Utils'; import { plainToHtml } from 'Common/UtilsUser'; @@ -504,7 +504,7 @@ export const MessageUserStore = new class { /-----BEGIN PGP SIGNED MESSAGE-----/.test(plain) && /-----BEGIN PGP SIGNATURE-----/.test(plain); } - const pre = doc.createElement('pre'); + const pre = createElement('pre'); if (pgpSigned && message.isPgpSigned()) { pre.className = 'b-plain-openpgp signed'; pre.textContent = plain; diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index 9305ee524..952295536 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -2,7 +2,7 @@ import ko from 'ko'; import { i18n } from 'Common/Translator'; import { isArray, isNonEmptyArray, pString } from 'Common/Utils'; -import { doc } from 'Common/Globals'; +import { createElement } from 'Common/Globals'; import { AccountUserStore } from 'Stores/User/Account'; @@ -361,7 +361,7 @@ export const PgpUserStore = new class { verControl.addEventHandler('click', domControlSignedClickHelper(this, dom, domText)); } - dom.before(verControl, doc.createElement('div')); + dom.before(verControl, createElement('div')); } } }