Re: [whatwg/dom] Basic DOM reactivity (Issue #1049)

If I understood @yonathan06 right, the idea wasn’t to observe DOM mutation, but rather to associate DOM mutation side effects with property assignment. Though the first example didn’t include the property assignment part.

There is a pretty well-proven need for more efficient templating primitives I think. This is where the (necessary) complexity in templating libraries tends to live today, so “textContent” might be too optimistic of an example. A solid model for updatable HTML template “substitution nodes” that can handle things like array mapping without every framework needing to reimplement it has probably got to come before novel surface API can be built on top.

I think there’s been a fair amount of exploratory work on that front (referred to as “template instantiation” or “template parts”). It’s a pretty big lift and I’m not sure what its current state is, though it seems like both Apple and Google were invested in pursuing its development. If it succeeds, it could provide that missing “update-by-value” layer, so if one’s preferred programming paradigm seems to be at odds with JS / the web platform, there’d only be a thin layer needed to map over to it.

I was looking at solidjs a bit and realized this discussion might concern “hooks” rather than just reactivity. Is that the case? I’m afraid it’s unlikely that that a platform API would promote/facilitate that today — it’s very creative but reinventing undefined behavior & memory unsafety over a language whose actual semantics exhibit neither is not exactly universally accepted. JS itself could one day introduce features that allow patterns of that sort to be realized safely, but there’s no linter-acting-as-a-compiler isn’t there once your site’s running in someone else’s browser.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1049#issuecomment-1024692724

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1049/1024692724@github.com>

Received on Friday, 28 January 2022 22:15:24 UTC