Skip to content

Validation consideration for the template tag #541

@studdugie

Description

@studdugie

Hello,

I've run into a practical/functional problem w/ how the spec treats HTML5's new template tag. The issue started out for me as a problem w/ validation but after raising the issue on the W3C's validator mailing list I've since learned that the validator is simply doing what the spec demands it does. Therefore I'm raising the issue here. But I'm going to explain it in terms of validation because that's how the problem ultimately manifests itself.

I am a web app developer and my shop makes extensive use of HTML5's template tag. Here are some actual examples from my work that highlight the problem (assume the root element is a template) :

  • img descendants whose src attributes are not set
  • time descendants whose text content is empty
  • Variants of the same form on a page that have a mutually exclusive relationship between themselves. The spec violation here is that some of the elements in the form are the same therefore they have the same IDs.

Technically speaking 1-3 violate the spec but functionally speaking they do not because the JavaScript process of turning an inert template into a live node in the DOM includes, in the case of 1 & 2, setting the src attribute and giving time its text content. In the case of 3, because the forms are mutually exclusive to each other only 1 of them will ever be made live.

So the crux of the issue we are having is that validation is tedious and error prone because every time we try to validate a page in our web app we are met w/ a litany of warnings and errors about all the things wrong w/ the descendants of each template element on the page, which significantly detracts from our ability to identify any legitimate issues with the page. It's so bad now that we have given up on validation entirely.

The only reason I've bothered to raise this issue is because I'm a follower of html5doctor.com on Twitter and recently reread this article, http://html5doctor.com/html5-check-it-before-you-wreck-it-with-miketm-smith/. Mike Smith's attitude struck a note w/ me. He represented the validator and the people behind it as being genuinely interested in helping and improving the lives of web developers. So I said to myself, "what the heck, the worse that could happen is nothing". But what I would actually like to see happen is that the spec be modified in such a way that allows a validator to stop complaining about the violations by children of template so that developers can focus on what is actually wrong w/ a page.

Thanks,

Dane

[UPDATE] I thought I should give a more concrete example of the form/id problem.
There is a template w/ a login form w/ user name and password fields and the associated ID attributes on both. There also exists a template w/ a create account form, which necessarily has user name and password fields w/ the same IDs as the login form. Only 1 of these forms can ever be live in the DOM so though the IDs are duplicates they never collide in the live DOM.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions