logoalt Hacker News

dpwebyesterday at 9:25 PM1 replyview on HN

The core idiom I've used for years is deliberately tiny: fully encapsulated custom Web Components that simply re-render when matching an attribute and `window.state` changes. Data model is simply:

  window.state = new Proxy({}, {
    set(target, key, value) {
      target[key] = value
      document.querySelectorAll(`[data="${key}"]`)
        .forEach(el => el.render?.())
      return true
    }
  })
handles reactivity.. https://github.com/digplan/vanilla-light

Replies

bosmarceltoday at 8:20 AM

Looks nice!

Imho, custom elements are great, but very limited in a way that they almost always require knowledge of the domain.

Perhaps I can figure out a way to combine mador.js & custom elements.