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

InvalidCharacterError with special character in attribute name #9566

Closed
wkwiatek opened this issue Jun 24, 2016 · 9 comments
Closed

InvalidCharacterError with special character in attribute name #9566

wkwiatek opened this issue Jun 24, 2016 · 9 comments
Labels
area: core Issues related to the framework runtime feature Issue that requests a new feature freq1: low help wanted An issue that is suitable for a community contributor (based on its complexity/scope). workaround1: obvious

Comments

@wkwiatek
Copy link
Contributor

wkwiatek commented Jun 24, 2016

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Creating input name for a component like test$ or something@ will produce error:

InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': 'ng-reflect-test$' is not a valid attribute name

Reproduction of the problem
http://plnkr.co/edit/p4AOGZsrmXgStWa9eDtf?p=preview

What is the expected behavior?
Valid JS name should also be a valid name in template.

Please tell us about your environment:
Mac OS X 10.11.5

  • Angular version: 2.0.0-rc.3
  • Browser: all
  • Language: TypeScript 1.8.10
@vicb
Copy link
Contributor

vicb commented Jun 24, 2016

Valid JS name should also be a valid name in template.

Well not exactly.... JS and HTML both have spec that tell you what is a valid name or name.

That being said, you are right for this particular case x-y$ is a valid html attribute name

"Failed to execute 'setAttribute' on 'Element': 'ng-reflect-test$' is not a valid attribute name" is your browser complaining, not angular. Which means that the bug is in your browser.

We will have to workaround this browser bug in Angular. Thanks for your report.

@vicb vicb added feature Issue that requests a new feature comp: core labels Jun 24, 2016
@wkwiatek
Copy link
Contributor Author

Maybe it's more like a wish but I think that having own html parser (which supports e.g. camelCase) could also make possible to put JS names as inputs.

Thanks!

@vicb
Copy link
Contributor

vicb commented Jun 24, 2016

  1. Our parser is (almost) HTML compliant,
  2. Once again this is not the problem here angular works just fine, see "the bug is in your browser." in my former response.

A workaround could be to set logBindingUpdate to false in the CompiilerConfig. (it is only true in dev mode by default).

@wkwiatek
Copy link
Contributor Author

wkwiatek commented Jun 24, 2016 via email

@vicb vicb added this to the 2.0.1 milestone Jun 24, 2016
@mhevery mhevery added area: core Issues related to the framework runtime and removed comp: core labels Sep 7, 2016
@vicb vicb modified the milestones: 2.0.1, 2.0.2 Sep 29, 2016
@vicb
Copy link
Contributor

vicb commented Oct 6, 2016

We need to sanitize the name so that all browsers are happy

@vicb vicb added the help wanted An issue that is suitable for a community contributor (based on its complexity/scope). label Oct 6, 2016
@minrwhite
Copy link

Can I take this one? My current line of thinking is that some form of reversible escaping will be necessary so there won't be conflicts between components with/without the special characters.

@vicb vicb removed this from the 2.0.2 milestone Dec 28, 2016
@miller-time
Copy link

When you provide an alternative binding string, such as @Input('test') test$, could the reflect attribute use the alias instead of the property? (i.e. "ng-reflect-test" instead of "ng-reflect-test$")

@maartentibau
Copy link
Contributor

Any news on whether or not this issue will be fixed? Or will this just be not an option as for HTML sanitation reasons?

DzmitryShylovich added a commit to DzmitryShylovich/angular that referenced this issue Feb 8, 2017
DzmitryShylovich added a commit to DzmitryShylovich/angular that referenced this issue Feb 8, 2017
DzmitryShylovich added a commit to DzmitryShylovich/angular that referenced this issue Feb 8, 2017
DzmitryShylovich added a commit to DzmitryShylovich/angular that referenced this issue Feb 9, 2017
DzmitryShylovich added a commit to DzmitryShylovich/angular that referenced this issue Feb 10, 2017
DzmitryShylovich added a commit to DzmitryShylovich/angular that referenced this issue Feb 10, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime feature Issue that requests a new feature freq1: low help wanted An issue that is suitable for a community contributor (based on its complexity/scope). workaround1: obvious
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants