TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Custom Elements v1: Reusable Web Components

101 pointsby markelliotalmost 8 years ago

13 comments

romanivalmost 8 years ago
Components with extensibility through inheritance written in a prototype-based language. Having worked with around a dozen component-based systems over the years I&#x27;m not particularly enthusiastic.<p>I think it would be much better for the web if browsers had a sane API for extending <i>behaviors</i> of any tag via attributes. This would make things easily composable and eliminate most problems of traditional component-based systems.<p><pre><code> &lt;button does-stuff does-more-stuff&gt;&lt;&#x2F;button&gt; </code></pre> It would be even better if people working on these specs spent some time reading research papers on how a sane component-based system <i>could</i> work. For example: <a href="http:&#x2F;&#x2F;alumni.media.mit.edu&#x2F;~mt&#x2F;thesis&#x2F;mt-thesis-Contents.html" rel="nofollow">http:&#x2F;&#x2F;alumni.media.mit.edu&#x2F;~mt&#x2F;thesis&#x2F;mt-thesis-Contents.ht...</a> A lot of interesting ideas regarding extensible behaviors and ease of understanding.<p>Edit: And yes, I&#x27;m aware of is=&quot;&quot; functionality. It&#x27;s not exactly what I&#x27;m talking about. In fact, if the specs were designed the way I mentioned, there would be no need for making anything special for built-in elements as opposed to the new ones.
评论 #15065291 未加载
评论 #15065703 未加载
SimeVidasalmost 8 years ago
This article has been added 5 days ago [1], in case anyone is wondering how recent it is.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;WebFundamentals&#x2F;commits&#x2F;master&#x2F;src&#x2F;content&#x2F;en&#x2F;fundamentals&#x2F;architecture&#x2F;building-components&#x2F;customelements.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;WebFundamentals&#x2F;commits&#x2F;master&#x2F;src...</a>
kevinSuttlealmost 8 years ago
This is the kicker for me:<p>&gt; At time of writing, no browser has implemented customized built-in elements. Chrome plans to implement them (status) but other browsers have expressed distaste for implementing the is=&quot;&quot; syntax.<p>I would love to just be able to &quot;fix&quot; the normalization around several built-in elements.
voiper1almost 8 years ago
Interesting. Only in Chrome 54&#x2F;Safari 10.1&#x2F;Opera 46 so far. <a href="http:&#x2F;&#x2F;caniuse.com&#x2F;#search=web%20components" rel="nofollow">http:&#x2F;&#x2F;caniuse.com&#x2F;#search=web%20components</a><p>But there&#x27;s a polyfill, and more discussion here:<p><a href="https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;fundamentals&#x2F;architecture&#x2F;building-components&#x2F;customelements#historysupport" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;web&#x2F;fundamentals&#x2F;architecture&#x2F;...</a>
VeejayRampayalmost 8 years ago
Excellent tutorial, as usual from Eric Bidelman. It&#x27;s a lot of information to digest though, one should take time with all the different bits and pieces covered in this article.
microo8almost 8 years ago
You can use custom elements also in golang :)<p><a href="https:&#x2F;&#x2F;github.com&#x2F;microo8&#x2F;golymer" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;microo8&#x2F;golymer</a>
macawfishalmost 8 years ago
I&#x27;ve had some success with Custom Elements, using skate.js as a higher level interface.<p>This piano keyboard element: <a href="https:&#x2F;&#x2F;micahscopes.github.io&#x2F;all-around-keyboard&#x2F;" rel="nofollow">https:&#x2F;&#x2F;micahscopes.github.io&#x2F;all-around-keyboard&#x2F;</a><p>Some elements for quickly drawing graphs in html: <a href="https:&#x2F;&#x2F;micahscopes.github.io&#x2F;tangled-web-components&#x2F;examples&#x2F;" rel="nofollow">https:&#x2F;&#x2F;micahscopes.github.io&#x2F;tangled-web-components&#x2F;example...</a><p>(It still needs some more convenient ways of defining the graph structure, as well as an interface to do force layouts.)<p>I haven&#x27;t worked on either project in a while. I kinda got tired working with the development version of skate.js while the custom elements spec was changing so fast. It&#x27;s an excellent library, but things were moving too quickly for me to keep up.<p>Today, I&#x27;d probably just do it in plain javascript, since the spec is more stable now.
megousalmost 8 years ago
Is it possible to nest custom elements? I suppose it should be, but how would it be seen in DOM?<p>&lt;my-container&gt; &lt;some-child some-attr&gt;&lt;&#x2F;some-child&gt; &lt;&#x2F;my-container&gt;<p>How can I get notifications in my-container when someone from outside adds another child to it?
评论 #15065572 未加载
评论 #15065602 未加载
评论 #15065689 未加载
pjmlpalmost 8 years ago
Customs Elements is what would make me quite happy with UI design on the browser side.<p>Now just have to wait a few years to be able to use it, or hope the polyfills actually cover all the browsers versions we might need to target.
albertTJamesalmost 8 years ago
could it replace React ?
评论 #15065120 未加载
cztomsikalmost 8 years ago
please correct me if I&#x27;m wrong but it seems that custom elements still do nothing about dependency hell (it&#x27;s not possible to use same lib in different versions)
评论 #15065192 未加载
megamindbrianalmost 8 years ago
Cool! I can&#x27;t wait for Google to abandon this!
dmitriidalmost 8 years ago
Custom Elements v1. Designed by committee: <a href="https:&#x2F;&#x2F;pbs.twimg.com&#x2F;media&#x2F;DALwpYnUAAESRjr.jpg" rel="nofollow">https:&#x2F;&#x2F;pbs.twimg.com&#x2F;media&#x2F;DALwpYnUAAESRjr.jpg</a><p>Polymer. Designed by people who actually do web development: <a href="https:&#x2F;&#x2F;pbs.twimg.com&#x2F;media&#x2F;DALwpYWVoAAIvkQ.jpg" rel="nofollow">https:&#x2F;&#x2F;pbs.twimg.com&#x2F;media&#x2F;DALwpYWVoAAIvkQ.jpg</a>
评论 #15063098 未加载
评论 #15063626 未加载
评论 #15063765 未加载