Giter VIP home page Giter VIP logo

Comments (12)

WebReflection avatar WebReflection commented on September 25, 2024 1

then I believe custom elements are the primitive you're looking for ... see uce, ube, or p-cool elements

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

if you come from vdom ... maybe you come from P/React and/or hooks? In that case, have you checked uland ?

from uhtml.

FbN avatar FbN commented on September 25, 2024

Thank you for the quick reply. I Looked at uland but I dont want to use on* events directly as attribute on elements. With ref= is possible to know when an element is created and attached to DOM. Is there a way to know when an element is removed from the DOM? If yes I think I can build the API as above

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

how did you hook into elements lifecycle before? nothing really different here ... but curious to know ... anyway, MutationObserver is there to help out with connected/disconnected things, but it requires your own integration here

from uhtml.

FbN avatar FbN commented on September 25, 2024

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

I see ... well, I have an alternative here: https://github.com/WebReflection/lighterhtml-plus#lighterhtml-plus

maybe one day I'll have the same in uhtml too ... the thing is, when those events matter, I usually go for Custom Elements right away, either builtin extend or regular

from uhtml.

FbN avatar FbN commented on September 25, 2024

I realized that ref=${callback} the callback is called with the element but befor it is attached to the DOM (when it's still resident on the document fragment). So I cannot access the node parent using ref=. Is it the desired behaviour?

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

Yes, because none of the things you are doing are documented as such for ref ... connected and disconnected are a different beast, but you can use ref to hook your node into that loop, still I don't know why you need it so desperately

from uhtml.

FbN avatar FbN commented on September 25, 2024

I want to attach a event listener to the parent of an html<><><><> result to capture events coming from the generated node in a programmatic way (to construct isolated components). This without any explict attribute wrote directly on html code or visible custom elements.

Something like

html`<div >${onButtonClick(callback)(html`<button  /><button /><button />`)}</div>`

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

you can do that via <div onclick=${callback}> ... not sure why you are trying to avoid what's uhtml all about 🤔

or use custom elements instead, so you have all connected/disconnected you

from uhtml.

FbN avatar FbN commented on September 25, 2024

from uhtml.

FbN avatar FbN commented on September 25, 2024

from uhtml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.