Use own createElement() instead of doc.createElement

This commit is contained in:
djmaze 2021-03-25 09:38:45 +01:00
parent 7eaaa0a793
commit 23e15fd161
6 changed files with 12 additions and 11 deletions

View file

@ -2,6 +2,7 @@ import ko from 'ko';
import { import {
doc, doc,
createElement,
elementById, elementById,
Settings Settings
} from 'Common/Globals'; } from 'Common/Globals';
@ -39,7 +40,7 @@ export class AbstractApp {
open(link, '_self'); open(link, '_self');
focus(); focus();
} else { } else {
const oLink = doc.createElement('a'); const oLink = createElement('a');
oLink.href = link; oLink.href = link;
doc.body.appendChild(oLink).click(); doc.body.appendChild(oLink).click();
oLink.remove(); oLink.remove();

View file

@ -1,7 +1,7 @@
import ko from 'ko'; import ko from 'ko';
import { Notification, UploadErrorCode } from 'Common/Enums'; import { Notification, UploadErrorCode } from 'Common/Enums';
import { langLink } from 'Common/Links'; import { langLink } from 'Common/Links';
import { doc } from 'Common/Globals'; import { doc, createElement } from 'Common/Globals';
let I18N_DATA = window.rainloopI18N || {}; let I18N_DATA = window.rainloopI18N || {};
@ -122,7 +122,7 @@ export function getUploadErrorDescByCode(code) {
*/ */
export function reload(admin, language) { export function reload(admin, language) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const script = doc.createElement('script'); const script = createElement('script');
script.onload = () => { script.onload = () => {
// reload the data // reload the data
if (window.rainloopI18N) { if (window.rainloopI18N) {

View file

@ -1,5 +1,5 @@
import { SaveSettingsStep } from 'Common/Enums'; import { SaveSettingsStep } from 'Common/Enums';
import { doc, elementById } from 'Common/Globals'; import { doc, createElement, elementById } from 'Common/Globals';
export const export const
isArray = Array.isArray, isArray = Array.isArray,
@ -119,7 +119,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
.then(data => { .then(data => {
if (data && isArray(data) && 2 === data.length) { if (data && isArray(data) && 2 === data.length) {
if (themeLink && !themeStyle) { if (themeLink && !themeStyle) {
themeStyle = doc.createElement('style'); themeStyle = createElement('style');
themeStyle.id = 'app-theme-style'; themeStyle.id = 'app-theme-style';
themeLink.after(themeStyle); themeLink.after(themeStyle);
themeLink.remove(); themeLink.remove();

View file

@ -2,7 +2,7 @@ import { ComposeType, FolderType } from 'Common/EnumsUser';
import { EmailModel } from 'Model/Email'; import { EmailModel } from 'Model/Email';
import { encodeHtml } from 'Common/Html'; import { encodeHtml } from 'Common/Html';
import { isArray } from 'Common/Utils'; import { isArray } from 'Common/Utils';
import { doc } from 'Common/Globals'; import { createElement } from 'Common/Globals';
/** /**
* @param {(string|number)} value * @param {(string|number)} value
@ -79,7 +79,7 @@ export function htmlToPlain(html) {
}; };
const const
tpl = doc.createElement('template'), tpl = createElement('template'),
convertPre = (...args) => convertPre = (...args) =>
args && 1 < args.length args && 1 < args.length
? args[1] ? args[1]

View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { Scope, Notification } from 'Common/Enums'; import { Scope, Notification } from 'Common/Enums';
import { MessageSetAction } from 'Common/EnumsUser'; 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 { isNonEmptyArray, pInt, pString, addObservablesTo, addSubscribablesTo } from 'Common/Utils';
import { plainToHtml } from 'Common/UtilsUser'; 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); /-----BEGIN PGP SIGNED MESSAGE-----/.test(plain) && /-----BEGIN PGP SIGNATURE-----/.test(plain);
} }
const pre = doc.createElement('pre'); const pre = createElement('pre');
if (pgpSigned && message.isPgpSigned()) { if (pgpSigned && message.isPgpSigned()) {
pre.className = 'b-plain-openpgp signed'; pre.className = 'b-plain-openpgp signed';
pre.textContent = plain; pre.textContent = plain;

View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { i18n } from 'Common/Translator'; import { i18n } from 'Common/Translator';
import { isArray, isNonEmptyArray, pString } from 'Common/Utils'; import { isArray, isNonEmptyArray, pString } from 'Common/Utils';
import { doc } from 'Common/Globals'; import { createElement } from 'Common/Globals';
import { AccountUserStore } from 'Stores/User/Account'; import { AccountUserStore } from 'Stores/User/Account';
@ -361,7 +361,7 @@ export const PgpUserStore = new class {
verControl.addEventHandler('click', domControlSignedClickHelper(this, dom, domText)); verControl.addEventHandler('click', domControlSignedClickHelper(this, dom, domText));
} }
dom.before(verControl, doc.createElement('div')); dom.before(verControl, createElement('div'));
} }
} }
} }