From 79b4c4f50547232ad3e828be0ac94e9707c46124 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 15 Sep 2022 16:31:40 +0200 Subject: [PATCH] Rewrite OC.SystemTags.getDescriptiveTag to vanilla js For every tag a deprecation warning is emitted. With 10k tags the ui becomes unresponsive and inspector crashed occasionally. Signed-off-by: Daniel Kesselberg --- core/src/systemtags/systemtags.js | 19 +++++++++++-------- core/src/systemtags/systemtagsinputfield.js | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/src/systemtags/systemtags.js b/core/src/systemtags/systemtags.js index 91ace6b3425d9..bbb2ecac1d87e 100644 --- a/core/src/systemtags/systemtags.js +++ b/core/src/systemtags/systemtags.js @@ -35,23 +35,24 @@ import escapeHTML from 'escape-html' /** * * @param {OC.SystemTags.SystemTagModel|Object|String} tag - * @returns {jQuery} + * @returns {HTMLElement} */ getDescriptiveTag: function(tag) { if (_.isUndefined(tag.name) && !_.isUndefined(tag.toJSON)) { tag = tag.toJSON() } + var $span = document.createElement('span') + if (_.isUndefined(tag.name)) { - return $('').addClass('non-existing-tag').text( - t('core', 'Non-existing tag #{tag}', { + $span.classList.add('non-existing-tag') + $span.textContent = t('core', 'Non-existing tag #{tag}', { tag: tag - }) - ) + }) + return $span } - var $span = $('') - $span.append(escapeHTML(tag.name)) + $span.textContent = escapeHTML(tag.name) var scope if (!tag.userAssignable) { @@ -62,7 +63,9 @@ import escapeHTML from 'escape-html' scope = t('core', 'invisible') } if (scope) { - $span.append($('').text(' (' + scope + ')')) + var $scope = document.createElement('em') + $scope.textContent = ' (' + scope + ')' + $span.appendChild($scope) } return $span } diff --git a/core/src/systemtags/systemtagsinputfield.js b/core/src/systemtags/systemtagsinputfield.js index 7c68a4b09ad31..1b6fb71f42dc2 100644 --- a/core/src/systemtags/systemtagsinputfield.js +++ b/core/src/systemtags/systemtagsinputfield.js @@ -292,7 +292,7 @@ import templateSelection from './templates/selection.handlebars' return templateResult(_.extend({ renameTooltip: t('core', 'Rename'), allowActions: this._allowActions, - tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null, + tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data).innerHTML : null, isAdmin: this._isAdmin }, data)) }, @@ -305,7 +305,7 @@ import templateSelection from './templates/selection.handlebars' */ _formatSelection: function(data) { return templateSelection(_.extend({ - tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null, + tagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data).innerHTML : null, isAdmin: this._isAdmin }, data)) },