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

Additonal schema with predefined non-angular elements #29803

Closed
BaerMitUmlaut opened this issue Apr 10, 2019 · 3 comments
Closed

Additonal schema with predefined non-angular elements #29803

BaerMitUmlaut opened this issue Apr 10, 2019 · 3 comments
Labels
area: core Issues related to the framework runtime
Milestone

Comments

@BaerMitUmlaut
Copy link

BaerMitUmlaut commented Apr 10, 2019

🚀 feature request

Relevant Package

This feature request is for @angular/core

Description

Currently there are two schemas available to allow non-angular custom elements and attributes:

  • CUSTOM_ELEMENTS_SCHEMA - ignores everything unknown
  • NO_ERRORS_SCHEMA - allows anythin dash-cased

However, there is no way to limit the allowed elements any further or to specify a number of allowed elements, for example to check for typos.

Describe the solution you'd like

I'd expand the SchemaMetadata interface like this:

export interface SchemaMetadata {
  name: string;
  tokenValid?: (token: string) => boolean;
}

The functions would check if the given token (element or attribute name) is valid, it's optional for full backwards compatibility (though that's probably not even necessary). Alternatively this could be split into two functions (attributeValid & elementValid).

Then there could be a class or helper function that generates an object which simply checks if the given token is within a set of previously defined tokens.

This would also clean up existing code because you don't have to hardcode the logic of the schema everywhere it's used.

If you approve, I can implement this and PR, should be pretty simple.

@pkozlowski-opensource pkozlowski-opensource added the area: core Issues related to the framework runtime label Apr 10, 2019
@ngbot ngbot bot added this to the needsTriage milestone Apr 10, 2019
@lacolaco
Copy link
Contributor

this is similar to #12045.

@BaerMitUmlaut
Copy link
Author

Oh I'm sorry, didn't find that one, looks like I made a duplicate. I will post my suggestion over there.

@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 14, 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
Projects
None yet
Development

No branches or pull requests

3 participants