aurelia / template-lint

Sanity check of Aurelia-flavor template HTML
Apache License 2.0
56 stars 17 forks source link

Bug: <template> as child of <ul> is not allowed #138

Closed zakjan closed 7 years ago

zakjan commented 7 years ago

template tag (or maybe even any containerless element) should be allowed

MeirionHughes commented 7 years ago

template is not a valid child of lists and tables. Browsers will ignore (remove) non-valid child markup when its parsed and its parsed before aurelia gets a hold of it (so you can't even have containerless).

zakjan commented 7 years ago

Oh :( ok

MeirionHughes commented 7 years ago

Its a pain; some guys in Aurelia team hit this too. The odd thing is spec says you should be able to have script/template items, but in reality the browsers are inconsistent.

Chrome will let you have template and its contents, but the contents will be a document fragment. Firefox seems to add a template element but with no contents.

If you want to disable the warning, you can change the config for the valid child rule, or disable it;

I may need to revisit this later if the situation changes.

zakjan commented 7 years ago

Thanks for explanation. I try to use ifs and repeats only on template tag, it looks cleaner then mixing into html, this is the only case where I can't do it.

If you want to disable the warning, you can change the config for the valid child rule, or disable it;

Rather not, better be consistent with all modern browsers.

MeirionHughes commented 7 years ago

https://gist.run/?id=33b8032f1c3236ed54cd80a5006c660e

As a sanity check; defo not working for me, even in chrome. :D

zakjan commented 7 years ago

But if you add if.bind="true", it works :D Chrome

MeirionHughes commented 7 years ago

Works in firefox too... how odd.

zakjan commented 7 years ago

Looks like template without any arguments is left unprocessed, while template with if.bind or repeat.for is processed correctly by Aurelia as containerless element.

MeirionHughes commented 7 years ago

So it would seem nested templates are allowed on pretty all the container-type html elements; even table and select. But you need to have a template-controller on the template, otherwise nothing happens. I will have a run through to fix it all.

MeirionHughes commented 7 years ago

I've temporarily added template as an allowed child of the html container elements; just a change of the default config to allow it. Comprehensive fix to be added in #142