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

Avoid using void element directives/components #164

Closed
bjarnef opened this issue Aug 9, 2020 · 3 comments
Closed

Avoid using void element directives/components #164

bjarnef opened this issue Aug 9, 2020 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@bjarnef
Copy link
Contributor

bjarnef commented Aug 9, 2020

In the various Vendr views I noticed some angular directives/components, which are void elements (self-closing).
For example:

<vendr-license-check /> and <umb-checkbox /> (e.g. inside vendrFilter directive).

However angular directives/components can't be self-closing, since these are custom HTML elements.
There is a great explanation of it here: https://stackoverflow.com/a/25012451/1693918

Furthermore this comment: https://stackoverflow.com/a/31724215/1693918

The browser's parser has to listen to the spec. Since using the slash in a non-void element tag is invalid, the parser ignores the ending />, and means . Therefore you are never closing the first element which prevents the others to work.

The browser's parser has to listen to the spec. Since using the slash in a non-void element tag is invalid, the parser ignores the ending />, and means . Therefore you are never closing the first element which prevents the others to work.

Here are some examples from Umbraco core where this caused issues:
umbraco/Umbraco-CMS#8478
umbraco/Umbraco-CMS#8605

I would therefore recommend always to use a end-closing tag:

<vendr-license-check></vendr-license-check>

<umb-checkbox></umb-checkbox> etc.

Regarding vendrFilter directive I noticed it has quite a lot of inline template markup, maybe move this to a separate view?

@bjarnef bjarnef added the enhancement New feature or request label Aug 9, 2020
@mattbrailsford
Copy link
Contributor

Good suggestion @bjarnef

Just a note to myself that I'll need to check the grunt build task as well as the source code to make sure it's not this that is minimizing the tags to their self closing counterpart.

@mattbrailsford
Copy link
Contributor

Fixed locally, will be in 1.2.8 patch release.

PS technically all directives end up being inline as we have a build process that actually reads the directive view files and inlines them. This is to save on the performance of having to load extra html files. We could move the template to a HTML file to make source code easier to navigate, but I don't think that affects users really.

@mattbrailsford mattbrailsford added this to the 1.2.8 milestone Aug 20, 2020
@mattbrailsford
Copy link
Contributor

1.2.8 is out now! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants