4

This is a follow up question to: Do Angular 5 components need a - in the selector?.

One of the benefits cited to having a dash (-) in an element name is that the element becomes an HTMLElement instead of an HTMLUnknownElement.

From a runtime point of view how does this matter? Does an HTMLUnknownElement start to seek out fame, get shunned by other elements, ...?

It almost seems like theres more benefit to being unknown. No paparazzi bothering you, etc. Plus since it's marked as unknown we know that it is a custom element.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Ole
  • 41,793
  • 59
  • 191
  • 359
  • You might as well get used to using the `-` dash since that complies with the web component naming rules. And if you ever move to Native components from Angular then you will need to use the dash. https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name – Intervalia Dec 18 '17 at 19:03
  • That's what I always had the impression of until I started doing various Angular youtube videos, and guys were just dispensing with the dash and making elements like `form01` with no obvious repercussions ... – Ole Dec 20 '17 at 00:21
  • It may not be bad to do it that way since it would distinguish between an Angular component and a true web component. But I tend to write _all_ of my components as native and use frameworks to manage the data. Angular works real well with native components if you supply the needed properties. – Intervalia Dec 20 '17 at 01:54

0 Answers0