Hyphen

Languages and libraries

web component library

SHOW HN2023

Hyphen

an elegant custom element base class with good ergonomics

github.com

#web components#custom elements#javascript#base class

36points
32comments
#1,276of 3,109 in 2023
Top 42%of 2023 by points

How HN took it

MixedNo clear lean

0 positive, 7 neutral or asking, 2 mixed, 7 critical, out of 16 comments about the project. Thread score -0.33.

Privacy: 0 for, 3 againstDocs: 0 for, 2 againstExecution: 0 for, 1 againstDesign: 0 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Clever and elegant code, good ergonomics

    From 2 comments
    • Odd that they chose to use the unsafe "eval", where there's a drop-in, safe(r) replacement with ``` const properties = Object.keys(injections); const values =…
      catapart on HN
    • Thank you for your kind words about Hyphen, catapart! And that is a very sweet little thing, the code. I like your bloody clever little code hack, that is pretty cool. I modified…
      keepamovin on HN
  • Good to see alternative approaches to web components

    From 2 comments
    • Odd that they chose to use the unsafe "eval", where there's a drop-in, safe(r) replacement with ``` const properties = Object.keys(injections); const values =…
      catapart on HN
    • Thank you for your kind words about Hyphen, catapart! And that is a very sweet little thing, the code. I like your bloody clever little code hack, that is pretty cool. I modified…
      keepamovin on HN

Objections

  • Uses eval, which is unsafe and breaks CSP

    From 3 comments
    • Odd that they chose to use the unsafe "eval", where there's a drop-in, safe(r) replacement with ``` const properties = Object.keys(injections); const values =…
      catapart on HN
    • Fair warning about the use of eval in the readme. Anyone caring about CSP headers can't use this project and that anyone should be everyone even though the CSP header is PITA to…
      morbicer on HN
    • Imho same problem as eval and on top of that it creates the function only in the global scope. Honestly it's a construct I've never seen out in the wild so I am not an expert.
      morbicer on HN
  • README was unclear about what the project does

    From 2 comments
    • I read the entire README and have absolutely zero idea what Hypen does (and I am a relatively experienced javascript/react programmer). Perhaps a 1-2 sentence explanation, plus…
      rco8786 on HN
    • Me neither. "An elegant custom element base class" could relate to any programming language. I skim the page and see angle brackets - so it's browser-related. Great - but for…
      andybak on HN
  • Name $ may conflict with jQuery-style naming

    From 1 comment
    • I’d suggest not naming the your main interface of your library “$”, for various obvious reasons.
      garrettjoecox on HN

Requests

  • Add a clearer one-sentence explanation and code examples

    From 2 comments
    • I read the entire README and have absolutely zero idea what Hypen does (and I am a relatively experienced javascript/react programmer). Perhaps a 1-2 sentence explanation, plus…
      rco8786 on HN
    • Thank you. That would be a great leading paragraph on their web page if anyone from the project is reading this.
      dhimes on HN
  • Link custom element term to a definition

    From 1 comment
    • It's really clear to me. (And I did account for the subsequent README commits since your comment). But that's probably because I already know Web Components well. I'm in the…
      verisimilidude on HN

Questions

  • How does the template scope variables like greeting and host

    From 2 comments
    • How does something like this work: ``` template() { return ` <span>$ {greeting}, $ {host.name}!</span> <button onclick="changeGreeting">Change Greeting</button> `; } ``` I don't…
      spankalee on HN
    • Here’s the function that evaluates the template: ``` with (this.state) { return eval(`(function $ {this.template.toString().replace(/^\s*function\s+/,'')}())`); } ``` So it’s…
      evan_ on HN

Alternatives named

  • Lit

    From 1 comment
    • This is correct. It's a wrapper around web components, kind of like Lit (which they credit in the acknowledgements). Web components are cool, but the spec is bare. This means, a…
      deanebarker on HN
  • jQuery

    From 1 comment
    • I’d suggest not naming the your main interface of your library “$”, for various obvious reasons.
      garrettjoecox on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/38149422)