Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid component name error for valid name that uses unicode characters #8564

Closed
youngrok opened this issue Jul 27, 2018 · 7 comments
Closed

Comments

@youngrok
Copy link
Contributor

Version

2.5.16

Reproduction link

https://jsfiddle.net/50wL7mdz/536596/

Steps to reproduce

  1. register component with unicode component name. ex: my-컴포넌트
  2. use it in template. ex: <my-컴포넌트></my-컴포넌트>
  3. Vue warn is logged and component is not rendered.

What is expected?

No error, no warning. The component should be rendered properly.

What is actually happening?

The component is not rendered with this warning.

[Vue warn]: Invalid component name: "my-컴포넌트". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.


Component-Names in Vue Guide says,

we strongly recommend following the W3C rules for custom tag names (all-lowercase, must contain a hyphen)

However, W3C rules allow lots of unicode characters for component name. I think these two rules are important:

  • They start with a lowercase ASCII letter, ensuring that the HTML parser will treat them as tags instead of as text.
  • They do not contain any uppercase ASCII letters, so user agents can always treat HTML elements ASCII-case-insensitively.

The rules prevent using uppercase ASCII letters, and does not force using only lowercase ASCII letters. They allow unicode characters, but Vue.js doesn't accept unicode component names.

Furthermore, the error level is not error but warn, but it doesn't work in some cases like using it as custom element in template. It works when routed by vue router.

@youngrok
Copy link
Contributor Author

I think two points should be fixed. First, html parser allows all XML QName.

const ncname = '[a-zA-Z_][\\w\\-\\.]*'

Second, validateComponentName allows all PotentialCustomElementName.

if (!/^[a-zA-Z][\w-]*$/.test(name)) {

@Justineo
Copy link
Member

Hi, can you elaborate on your use case for this feature? We want to make sure the feature is not just for achieving maximum flexibility while lacks real use case.

we strongly recommend following the W3C rules for custom tag names (all-lowercase, must contain a hyphen)

As I understand, by mentioning the spec about custom tag names we actually want to apply more restrictions here. And in fact you can tell this intention from the warning message already:

Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.

Technically a subset of HTML is still HTML-compliant so applying extra restrictions like this won't break the standard.

@youngrok
Copy link
Contributor Author

Hi, let me explain my cases. I'm working on tax reporting software in Korea. So many items are required for tax reporting, and so many terms are used in those items, and they are all Korean.

For the first time I tried to translate all the terms to English, but failed because some don't have standard translation, some have same translation but different meaning, some have subtle difference of meaning, and so on. And it wasn't efficient to translate all of them.

Therefore, I changed my mind to use the Korean terms as they are, and this new way works for server side and dbms perfectly. It also works for plain javascript. However, vue.js doesn't support unicode names in some cases, so I want to make it work.

I think my case is not so rare case. Lots of developers want to use there native language in code especially when developing software that uses many complicated terms.

Technically a subset of HTML is still HTML-compliant so applying extra restrictions like this won't break the standard.

I understand. You're right. Then what I need is not a fix, but an improvement.

@posva
Copy link
Member

posva commented Aug 17, 2018

It's funny because I am on the same page as @Justineo but I faced that problem as well in French projects and used French terms for things that cannot or are very difficult to be translated. The only difference is that I can just ignore accents and ç and use plain letters

@youngrok
Copy link
Contributor Author

How is it going? Could you tell me whether this issue would be accepted or not?

@vuejs vuejs deleted a comment from hg-pyun Aug 28, 2018
@yyx990803
Copy link
Member

Closed via #8666 - thanks for the contribution!

f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
@42mypark
Copy link

42mypark commented Dec 9, 2019

Hi, I'm a student learning vuejs as my first framework. I want to use my component name in my language.I read what you commented on 27 jul 2018. but I don't understand about that. I don't have these files 'vue/src/compiler/parser/html-parser.js' and ' vue/src/core/util/options.js'.

I installed and setup vue this commend
** npm install -g @vue/cli
** vue create frontend

what should I do? I really want to use component name in my language. please give me your help.
@youngrok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants