You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2020/04/14 15:27:51 UTC

[sling-org-apache-sling-app-cms] branch master updated: Fixes SLING-9369: Removing wrapping span

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git


The following commit(s) were added to refs/heads/master by this push:
     new 5c867fc  Fixes SLING-9369: Removing wrapping span
5c867fc is described below

commit 5c867fc13970985782c09073ab178ca6f9571c9b
Author: Dan Klco <dk...@apache.org>
AuthorDate: Tue Apr 14 11:27:32 2020 -0400

    Fixes SLING-9369: Removing wrapping span
---
 ui/src/main/frontend/js/cms.labelfield.js | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/ui/src/main/frontend/js/cms.labelfield.js b/ui/src/main/frontend/js/cms.labelfield.js
index 367ef10..328cd89 100644
--- a/ui/src/main/frontend/js/cms.labelfield.js
+++ b/ui/src/main/frontend/js/cms.labelfield.js
@@ -24,11 +24,11 @@ rava.bind('.labelfield', {
         event.preventDefault();
         event.stopPropagation();
         const context = this;
-        const span = document.createElement('span');
+        const tmp = document.createElement('span');
         const val = context.querySelector('.labelfield__field input').value;
         let found = false;
         const title = context.querySelector(`option[value="${val}"]`).innerText;
-        span.innerHTML = context.querySelector('.labelfield__template').innerHTML;
+        tmp.innerHTML = context.querySelector('.labelfield__template').innerHTML;
         context.querySelectorAll('.labelfield__item input').forEach((el) => {
           if (el.value === val) {
             found = true;
@@ -37,12 +37,16 @@ rava.bind('.labelfield', {
         if (found) {
           return;
         }
-        span.querySelector('input').value = val;
-        span.querySelector('.labelfield__item').title = val;
+        tmp.querySelector('input').value = val;
+        tmp.querySelector('.labelfield__item').title = val;
 
         if (title !== '') {
-          span.querySelector('.labelfield__title').innerText = title;
-          this.closest('.labelfield').querySelector('.labelfield__container').appendChild(span);
+          tmp.querySelector('.labelfield__title').innerText = title;
+          tmp.childNodes.forEach(c => {
+            const child = c.cloneNode(true);
+            this.closest('.labelfield').querySelector('.labelfield__container').appendChild(child);
+          });
+          tmp.remove();
           context.querySelector('.labelfield__field input').value = '';
         }
       },