InHerAtENCe?!?!
Former-commit-id: a5c9ef76c3e33a827750132bcaf758f87498a588
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { RegisterComponent, Component, SideLoad } from './components.mjs';
|
||||
|
||||
class CompactProductListing extends Component {
|
||||
static __IDENTIFY => 'compact-listing';
|
||||
static __IDENTIFY() { return 'compact-listing'; }
|
||||
|
||||
constructor() {
|
||||
super(CompactProductListing);
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
export async function SideLoad(path) {
|
||||
return await fetch(path).then(response => response.text());
|
||||
// it is important that no more than content than
|
||||
// neccesary is fetched from the server
|
||||
const preLoadCache = [];
|
||||
export function SideLoad(path) {
|
||||
console.log(preLoadCache);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
if (preLoadCache[path]) {
|
||||
resolve(preLoadCache[path]);
|
||||
} else {
|
||||
const fetchPromise = fetch(path).then(response => response.text());
|
||||
preLoadCache[path] = fetchPromise;
|
||||
resolve(fetchPromise);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function RegisterComponent(componentClass) {
|
||||
@@ -25,7 +38,6 @@ export class Component extends HTMLElement {
|
||||
OnceRendered() { this.__WARN('Render'); }
|
||||
static __IDENTIFY() { this.__WARN('identify'); }
|
||||
|
||||
|
||||
connectedCallback() {
|
||||
// set up to watch all attributes for changes
|
||||
this.watchAttributeChange(this.attributeChangedCallback.bind(this));
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
const menuToggler = document.querySelector('navbar-component').shadowRoot.querySelector('#menu-toggler');
|
||||
const navMenu = document.querySelector('navbar-component').shadowRoot.querySelector('.navbar');
|
||||
|
||||
menuToggler.addEventListener('click', function() {
|
||||
menuToggler.classList.toggle('menu-active');
|
||||
navMenu.classList.toggle('menu-active');
|
||||
});
|
||||
@@ -15,6 +15,13 @@ class NavBar extends Component {
|
||||
}
|
||||
|
||||
OnceRendered() {
|
||||
const menuToggler = document.querySelector('navbar-component').shadowRoot.querySelector('#menu-toggler');
|
||||
const navMenu = document.querySelector('navbar-component').shadowRoot.querySelector('.navbar');
|
||||
|
||||
menuToggler.addEventListener('click', function () {
|
||||
menuToggler.classList.toggle('menu-active');
|
||||
navMenu.classList.toggle('menu-active');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user