matthewp / bram

Web components, live bound templates, in 4kB

Home Page:https://bramjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should renderMode=light replace the element's child

matthewp opened this issue · comments

I think the answer is yes, however, if you had a template like:

<template>
  Hello {{name}}
</template>

And an element like:

class MyElement extends Bram.Element {
  static get template() {
    return document.querySelector('template');
  }
  static get renderMode() {
    return 'light';
  }
}
customElements.define('my-element', MyElement);

Being used like:

<my-element>Some inner stuff</my-element>

Would you expect it to replace the inner contents with the template or just append? Currently it appends, but that feels wrong to me.

My two bobs - I agree, should replace. Appending feels a little magical, and hard to keep track of the DOM state. If an element renders into it's light DOM, it makes sense that the element itself would dictate all of it's light DOM - the author should just document as such. Also seems a bit arbitrary if it appends the template, as opposed to prepending, or injecting somewhere else in the content...though that might just be me being overly pedantic.

Cool, I agree. Yeah, there's no reason to keep the children in place. I'll go ahead and fix this one.

Released as 0.6.2