[HN Gopher] Show HN: Web-directive.js - A directive pattern for ...
       ___________________________________________________________________
        
       Show HN: Web-directive.js - A directive pattern for native HTML
        
       A library to implement directive pattern for native HTML without
       any framework, which is inspired by Vue.js.
        
       Author : asika32764
       Score  : 9 points
       Date   : 2025-10-19 13:41 UTC (9 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | jauntywundrkind wrote:
       | Similar but different, I really dig the nice spatial/3d
       | webcomponent https://Lume.io 's ECS / behavior system. Standalone
       | library, works for anything. https://github.com/lume/element-
       | behaviors
       | 
       | Here, the presence of an attribute signals behavior. With
       | element-behaviors, has= attribute is used to say what behavior
       | classes to apply. Different paths but doesn't seem super
       | dissimilar end result. I feel like web-directive giving a simple
       | callback leaves a lot to the developer, where-as element-
       | behaviors API surface tries to parallel WebComponents, which is
       | familiar & has lots of nice understandable lifecycle builtin.
        
       | mock-possum wrote:
       | This looks kinda neat - I'm not really sure I have a good sense
       | of what I would use this for though.
       | 
       | If I'm working in vanilla js, I don't really have any issues when
       | using element selectors - deferred or otherwise.
       | 
       | If I'm working in an app framework, then that framework already
       | provides this functionality - for instance Lit lets you bind
       | event listeners to elements as defined in your templates @event-
       | name=${this.onEventName}
       | 
       | I guess - is the aim with this, that it's useful for if you're
       | working outside the context of a specific site or project, and
       | aiming to write code for an npm package or similar, where you
       | need something portable and framework-independent? I suppose I
       | could see reaching for it in that case.
        
       ___________________________________________________________________
       (page generated 2025-10-19 23:02 UTC)