From 96285fee02de0693fc0d7b588074950af75cbb46 Mon Sep 17 00:00:00 2001 From: Erik Gassler Date: Thu, 20 Jun 2024 14:07:05 -0500 Subject: [PATCH] fix check for p tag --- Cargo.lock | 2 +- webapp/root_files/sitemap.xml | 8 ++++---- webapp/wc/template.js | 32 +++++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efaeaa5..e160ba1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1309,7 +1309,7 @@ dependencies = [ [[package]] name = "webui" version = "0.10.5" -source = "git+https://github.com/StoicDreams/RustWebUI?branch=main#03c5d04349a79029060f5b09de6a431d0c83d702" +source = "git+https://github.com/StoicDreams/RustWebUI?branch=main#3c3f84c66aa8fe3d10378859d13428fbbf061cd0" dependencies = [ "async-std", "chrono", diff --git a/webapp/root_files/sitemap.xml b/webapp/root_files/sitemap.xml index 4fe34cc..d73978c 100644 --- a/webapp/root_files/sitemap.xml +++ b/webapp/root_files/sitemap.xml @@ -2,18 +2,18 @@ https://www.taskproxy.com"/" - 2024-06-19 + 2024-06-20 https://www.taskproxy.com"/about" - 2024-06-19 + 2024-06-20 https://www.taskproxy.com"/privacy" - 2024-06-19 + 2024-06-20 https://www.taskproxy.com"/terms" - 2024-06-19 + 2024-06-20 diff --git a/webapp/wc/template.js b/webapp/wc/template.js index d4f2b1a..c10eb6d 100644 --- a/webapp/wc/template.js +++ b/webapp/wc/template.js @@ -1,16 +1,26 @@ -/* Template for web components. */ +/* Template for open web components. */ "use strict" { - // Start open Template + function toCamel(property) { + return property.replace(/(-[A-Za-z0-9]{1})/g, a => { return a[1].toUpperCase(); }); + } class OpenTemplate extends HTMLElement { constructor() { super(); const t = this; + if (t.parentNode && t.parentNode.nodeName === 'P') { + let p = t.parentNode; + t.parentNode.parentNode.insertBefore(t, t.parentNode); + if (p.innerHTML.trim() === '') { + p.remove(); + } + } } static get observedAttributes() { return []; } attributeChangedCallback(property, oldValue, newValue) { + property = toCamel(property); if (oldValue === newValue) return; if (newValue === null || newValue === undefined) { delete this[property]; @@ -22,9 +32,11 @@ disconnectedCallback() { } } customElements.define('app-open-template', OpenTemplate); - // End Open Template +} - // Start Shadow Template +/* Template for open web components. */ +"use strict" +{ const template = document.createElement('template') template.setAttribute('shadowrootmode', true); template.innerHTML = ` @@ -35,10 +47,20 @@ `; + function toCamel(property) { + return property.replace(/(-[A-Za-z0-9]{1})/g, a => { return a[1].toUpperCase(); }); + } class ShadowTemplate extends HTMLElement { constructor() { super(); const t = this; + if (t.parentNode && t.parentNode.nodeName === 'P') { + let p = t.parentNode; + t.parentNode.parentNode.insertBefore(t, t.parentNode); + if (p.innerHTML.trim() === '') { + p.remove(); + } + } const shadow = t.attachShadow({ mode: 'open' }); t.template = template.content.cloneNode(true); shadow.appendChild(t.template); @@ -47,6 +69,7 @@ return []; } attributeChangedCallback(property, oldValue, newValue) { + property = toCamel(property); if (oldValue === newValue) return; if (newValue === null || newValue === undefined) { delete this[property]; @@ -58,5 +81,4 @@ disconnectedCallback() { } } customElements.define('app-shadow-template', ShadowTemplate); - // End Shadow Template }