“299742-nowjedi-hello” is not a valid Custom Element name

只愿长相守 提交于 2020-07-23 07:02:21

问题


I am quite new on component development and struggling printing a simple hello world. Can someone help me?

Steps to reproduce:

1. now-cli login --host stack.service-now.com
2. now-cli project --name nowjedi-hello -- description 'A web component printing Hello World'
3. npm install
4. now-cli develop --open

Returns:

SyntaxError: Failed to execute 'define' on 'CustomElementRegistry': "299742-nowjedi-hello" is not a valid custom element name

I am following "Developing your component". Any idea what going on? https://developer.servicenow.com/dev.do#!/guide/orlando/now-experience/cli/development-flow/.


回答1:


You can't start a name with a digit

source: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name

short summary:

  • start with an ASCII lower alpha, so the HTML parser will treat them as tags instead of as text.

  • do not contain any ASCII upper alphas.

  • contain (at least) one hyphen, used for namespacing and to ensure forward compatibility.

A large variety of names is allowed, to give maximum flexibility for use cases like:
<math-α> or <emotion-😍>



来源:https://stackoverflow.com/questions/60667115/299742-nowjedi-hello-is-not-a-valid-custom-element-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!