10 ms·
There is a subtle grain of truth to it - the implied "declaratively" here. React has went south quite a bit, but the basic idea of JSX where HTML becomes a lang
by spion 3y ago
There is a subtle grain of truth to it - the implied "declaratively" here. React has went south quite a bit, but the basic idea of JSX where HTML becomes a language with first class objects, functions and bindings is extremely compelling. It offers a solution to the problems of complexity that pure HTML cannot tackle while still staying somewhat true to its declarative nature and reaping most of those benefits (instead of fully switching to the imperative DOM paradigm).
- spankalee 3y agoAdding "declaratively" doesn't make it true either. You can declaratively pass objects between web components in every web components library out there like Lit or Stencil. Now, you may claim that that doesn't count because the declarative part is implemented in non-standard userland libraries, to which I would reply: 1) So what? React is a non-standard userland library. You can't pass data declaratively between React components without React. At least with web components there's a standard _interface_ for the components so that many different libraries can implement the declarative parts in a completely interoperable way. 2) Yes, you can't pass objects around in plain HTML because plain HTML doesn't have references to the objects in the first place. Even if you did add a way to set properties in HTML, what would you set them to? 2b) This is actually likely changing as the Template Instantiation proposal moves along and possibly gets the ability to make property bindings. This will be useful for declaring custom elements that accept properties. But the question remains: where do those properties originate from? Most likely JavaScript, because HTML doesn't have any.
- Izkata 3y ago> You can declaratively pass objects between web components in every web components library out there like Lit or Stencil. They capitalized Web Components, I think they're talking about what browsers natively support and not a library or framework.
- troupo 3y ago> You can declaratively pass objects between web components in every web components library out there like Lit or Stencil. This makes it a non-standard library-specific method of passing things. I have no idea what you're arguing against. There's literally no way to pass objects as attributes to web components. Web components had a great opportunity to get rid of attributes/properties dichotomy, but they doubled down on them. > At least with web components there's a standard _interface_ for the components so that many different libraries can implement the declarative parts in a completely interoperable way. Of course there's nothing standardised, and nothing interoperable. Because if one web component exposes its API through attributes, and the other one through properties, and a third one through both, never the three shall meet. Without library-specific hacks. There's a reason the "standardized" lit uses a custom DSL to distinguish between things: `<some-component attribute="string only" ?boolean=${boolean} .property=${any_js_variable} @event_name=${callback_function} >` So much standardization. Edit: Stencil uses JSX (non-standard), so it doesn't care and probably sets properties directly, skipping attributes. For object props and HTML it says it explicitly that you cannot set them (of course): https://stenciljs.com/docs/properties#object-props https://stenciljs.com/docs/properties#object-props > But the question remains: where do those properties originate from? Most likely JavaScript, because HTML doesn't have any. Indeed. That is another issue with anything web-component-related. Moar Javascript. As if we don't have enough. There are now dozens of more JS APIs existing just because of web components, and even more are incoming: https://w3c.github.io/webcomponents-cg/2022.html https://w3c.github.io/webcomponents-cg/2022.html
- spankalee 3y ago> Of course there's nothing standardised, and nothing interoperable. This is so very much not true. On what basis do you even claim this? Web components are JavaScript objects that extend from HTMLElement. They all share a common interface of attributes, children, events and properties. You can get a reference to any web components any set a property on it: document.querySelector('my-element').someProp = {}; This works on all web components. It's interoperable because there's no special React, or Angular, or Vue version of an API to set properties. > There's literally no way to pass objects as attributes to web components How do you even get a reference to an object in HTML to pass as an attribute, if you could? And who cares? You can pass objects as properties to web components. Attributes are string-valued, why would you want to pass an object to them?