Live data from Hacker News

Web Components could replace frontend frameworks?

dannymoerkerke.com

161–170 of 248 posts

Re: Web Components could replace frontend frameworks?

#161

Earlier quoted context omitted.

Honest question: How is React/vue/etc. different in this regard?

React is pure JS, no string parsing is involved at runtime (JSX is just function calls [1]). Vue has its own templating language that gets compiled to function calls that are very similar to React’s [2]. I have my fair share of criticisms against Vue (as any templating system, it’s quite inconsistent[3]). I don’t think any of them just dump string blobs via innerHtml. And I doubt any of them parse strings with regexp…

> React is pure JS, no string parsing is involved at runtime (JSX is just function calls [1]).

Why does this matter? React still eventually compiles down to DOM operations whether that be innerHTML or XML modifications.

Re: Web Components could replace frontend frameworks?

#162
post #101

I worked with Polymer-based components ~2 years ago (an eternity in frontend-land), and I want to share my biggest pain point: you may want to integrate a ` `, but it does not "look right" in your design (eg white website, but the carousel has a black background). If the author did not set up CSS variables, you have to either try overriding stuff, or fork it. This problem is why every organization (eg GE with Predix…

Web Components are an anti-pattern

Please expand on this point?

Re: Web Components could replace frontend frameworks?

#163

Earlier quoted context omitted.

The lit-plugin VS Code extension provides type-checking and code-completion for lit-html temptlates. The approach can be adopted for a tsc plugin.

It’s still opaque string blobs no matter how you try to dress them up. —- I should probably edit this: It’s still string blobs that are totally opaque to the browser, and that are parsed with regular expressions[1] at runtime[2] and dumped into DOM via innerHtml[3]. [1] https://github.com/Polymer/lit-html/blob/61c08a615abadbe58bc... [2] http://exploringjs.com/es6/ch_template-literals.html [3] https://github.com/Polym…

It's a bit disingenuous to say the templates are parsed with regular expressions. The way lit-html generates DOM Templates from strings is by letting the browser parse the string through innerHTML. The purpose of the regexes you are referring to is to find the correct insertion points for dynamic values in the template, and has nothing to do with the HTML parsing process.

There is nothing fundamentally wrong with using innerHTML to parse HTML strings. You use the same parser for the content of index.html, and I don't think anyone is advocating to replace index.html with a single script that creates these nodes using a virtualDOM type rendering system.

Re: Web Components could replace frontend frameworks?

#164
I've written a couple of smaller and larger apps in Angular 1 and 2, Vue, React, Polymer and recently trying out lit-element and it solves pretty much all my needs. I like the typescript decorators for properties and elements and that is the only reason for which I need Webpack. Redux, the part of it I need which is updating from a central store, I replaced with about 20 lines of javascript.

Because of how good web components in their current state are my very personal opinion is that the other frameworks I have written code in solve yesterday's problems and are very likely to become the future jQuerys.

Re: Web Components could replace frontend frameworks?

#166
post #86

Earlier quoted context omitted.

When you control the data, innerHTML is fine. It's only untrusted data coming from the user that's the problem.

Only if you can, with absolute certainty, keep track of which of those is which, and never have it change, or have some offline process polute data that was supposed to be clean. There is almost never a reason to use innerHTML, and by avoiding it you reduce the surface that could be attacked.

apart from where you actually have html formatted text. not plain text.

Re: Web Components could replace frontend frameworks?

#167

Web Components don’t offer a declarative way of updating the DOM; it’s still `innerHTML` and using DOM APIs to edit the state of the live DOM. Backbone was a hassle to manage in any sizeable app because updating the view was left up to every dev to figure out themselves. React brought a declarative wrapper around the statefulness of the DOM, and that is the killer feature that Web Components does not offer at all. Vu…

Yeah, articles that proclaim the end of frameworks due to Web Components always revolve around a misunderstanding of what those frameworks bring. This article, likewise, starts out on the same incorrect premise:

> [Frameworks like Angular and React] have enabled us to do what we always wanted but never were able to: creating reusable autonomous frontend components

That's not what we always wanted to do, and not why people are using these frameworks. How often do you re-use your Angular and React application?

Re: Web Components could replace frontend frameworks?

#168
post #167

Web Components don’t offer a declarative way of updating the DOM; it’s still `innerHTML` and using DOM APIs to edit the state of the live DOM. Backbone was a hassle to manage in any sizeable app because updating the view was left up to every dev to figure out themselves. React brought a declarative wrapper around the statefulness of the DOM, and that is the killer feature that Web Components does not offer at all. Vu…

Yeah, articles that proclaim the end of frameworks due to Web Components always revolve around a misunderstanding of what those frameworks bring. This article, likewise, starts out on the same incorrect premise: > [Frameworks like Angular and React] have enabled us to do what we always wanted but never were able to: creating reusable autonomous frontend components That's not what we always wanted to do, and not why p…

I reuse react components ALL the time.

I think the problem with the article is that it is just looking at components (as a developer I have wanted the encapsulation this methodology brings), whereas react offers more than that - the virtual DOM, for example.

Re: Web Components could replace frontend frameworks?

#169
post #146

Earlier quoted context omitted.

> If it's that simple, could you consider replacing the first 1k words with this instead? No. I am not going to change anything because strangers online cannot read. If you have a better approach submit a pull request.

One does wonder what the point is of trying to communicate something, if the speaker does not care about whether the listener understands their message...

This can be seen in scientific papers as well as in some books.

It is based on the literacy of the powerful that we know from the dark ages. To use complex language as a substitute for easier formulations is a tool for literate people to prevent lesser educated people from understanding their texts.

Re: Web Components could replace frontend frameworks?

#170

I worked with Polymer-based components ~2 years ago (an eternity in frontend-land), and I want to share my biggest pain point: you may want to integrate a ` `, but it does not "look right" in your design (eg white website, but the carousel has a black background). If the author did not set up CSS variables, you have to either try overriding stuff, or fork it. This problem is why every organization (eg GE with Predix…

As others have already answered styling into Components is still hard, but there are answers coming soon with part/theme and Scoped Stylesheets.

Also, ZephJS, the Web Components library I am championing, has the ability to inherit from another ZephJS element which allows one to add to or even completely replace the styles for the new element without any special css magic. So if I want to style I simply inherit from it in my new and I can style however I want.

https://gist.github.com/arei/8083a6270e704b830c68a2020f3e5e3...

Post reply on HN