Skip to content

Commit

Permalink
fix check for p tag
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgassler committed Jun 20, 2024
1 parent 4c9951e commit 96285fe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions webapp/root_files/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.taskproxy.com"/"</loc>
<lastmod>2024-06-19</lastmod>
<lastmod>2024-06-20</lastmod>
</url>
<url>
<loc>https://www.taskproxy.com"/about"</loc>
<lastmod>2024-06-19</lastmod>
<lastmod>2024-06-20</lastmod>
</url>
<url>
<loc>https://www.taskproxy.com"/privacy"</loc>
<lastmod>2024-06-19</lastmod>
<lastmod>2024-06-20</lastmod>
</url>
<url>
<loc>https://www.taskproxy.com"/terms"</loc>
<lastmod>2024-06-19</lastmod>
<lastmod>2024-06-20</lastmod>
</url>
</urlset>
32 changes: 27 additions & 5 deletions webapp/wc/template.js
Original file line number Diff line number Diff line change
@@ -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];
Expand All @@ -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 = `
Expand All @@ -35,10 +47,20 @@
<slot></slot>
<slot name="something"></slot>
`;
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);
Expand All @@ -47,6 +69,7 @@
return [];
}
attributeChangedCallback(property, oldValue, newValue) {
property = toCamel(property);
if (oldValue === newValue) return;
if (newValue === null || newValue === undefined) {
delete this[property];
Expand All @@ -58,5 +81,4 @@
disconnectedCallback() { }
}
customElements.define('app-shadow-template', ShadowTemplate);
// End Shadow Template
}

0 comments on commit 96285fe

Please sign in to comment.