Regarding the "Use multi-word component names" rule. #9340
Replies: 2 comments 3 replies
-
I think the important sentence here is in the second "Notes" section:
I read that as: "If you create a custom element, it has to contain a hyphen (i.e. consist of two words), because no elements will ever be added to HTML, SVG, or MathML that contain a hyphen (i.e. only single word elements will ever be added to HTML, SVG, or MathML)". |
Beta Was this translation helpful? Give feedback.
-
It would still be a conflict when you use uppercase name in-DOM template. e.g. BTW, the style guide page you mentioned is actually not actively maintained. There is no link from the homepage to it. Not sure how you found it. 😅 Thanks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I understand this has probably been asked so many times, but the "Use multi-word component names" rule just confuses me. The description of the rule reads:
The words "prevents conflicts" link to the HTML spec, but the section it links to says nothing about element names being single words. In fact, the section only refers to custom elements, so even if it did say that the names have to be a single word, it would really only be for custom elements and provide no guarantee that any new HTML elements would follow those rules. It would be a good sign, but not a guarantee. Yes, most (if not all, save for arguably
textarea
) of commonly used HTML elements are a single word, there's no guarantee this will be the case going forward.The conflicts in question also only arise of components are being used in their lowercase form (HTML templates). Using the uppercase form (SFC templates) completely eliminates the possibility of conflicts. I'm not sure what the breakdown is of what Vue developers use what kind of templates, but calling a pattern "essential" (as per the title of the section it is in) to avoid conflicts that only happen in certain usecases feels a bit overly regimented, in my opinion.
So not only is the claimed justification for the rule actually not the case, but it also is meant to solve conflicts that only exist in certain usecases.
I don't think it's a bad rule for those usecases, but to call it "essential" is too much (again, in my opinion). Am I missing something? I could be misreading the HTML spec, but I really cannot see how the linked section enforces anything about the number of words in an element name.
Beta Was this translation helpful? Give feedback.
All reactions