o0101 / good.html

💎 Good.HTML. A nice framework without the bad stuff. Lots of custom elements, and nice templates. Good. HTML
https://o0101.github.io/good.html/
MIT License
21 stars 2 forks source link

to do #14

Closed o0101 closed 2 years ago

o0101 commented 2 years ago
o0101 commented 2 years ago

re the node removed bug

i think i have an idea

when i insert nodes into document

i could create a map, node => cachedKey/instanceKey

so that upon removal, i create a set of the keys for all nodes removed, and then go through those keys removing them from the cache...next time the node is called (upon intending for it to be back in the view) it should be called first time and re-inserted into the DOM)

o0101 commented 2 years ago

I think I can do this before I return retVal

o0101 commented 2 years ago

about linkedCustomElement I think I have a quick and easy fix that avoids having to parse the attributes from the comment text content (as comments don't have attributes), we do this:

const df = document.createDocumentFragment();
const div = document.createElement('div');
df.appendChild(div);
div.insertAdjacentHTML('afterBegin', `
  <span ${bangTag.textContent}></span>
`)
const span = div.querySelector('span');
Array.from(span.attributes).forEach(({name, value}) => {
  if ( ! value && name.matches(DOUBLE_BARREL) ) return; // i.e., it's the bang tag name
  lce.setAttribute(name, value);
});

// and then we have the attributes and we can update
o0101 commented 2 years ago

so in the above example we get the attributes parsed automatically for us by assigning a string containing them to be the tag content of a span element created with insertAdjacentHTML

pretty fucking clever

o0101 commented 2 years ago

And it's done! :P ;) xxx