NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 853 - Disallow <link> from having both rel='' and itemprop=''
Disallow <link> from having both rel='' and itemprop=''
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: HTML5 schema
HEAD
All All
: P2 normal
Assigned To: Michael[tm] Smith
http://html5.org/tools/web-apps-track...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-09 23:33 CEST by Philip Jägenstedt
Modified: 2011-08-19 16:16 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Jägenstedt 2011-08-09 23:33:59 CEST
It appears that the validator always requires <link> to have a rel attribute.

Henri, can this constraint be expressed in a schema or should I add it to Assertions.java?
Comment 1 Michael[tm] Smith 2011-08-10 00:39:29 CEST
(In reply to comment #0)
> It appears that the validator always requires <link> to have a rel attribute.
> 
> Henri, can this constraint be expressed in a schema or should I add it to
> Assertions.java?

This is something that should be expressed in the schema. I'm happy to make the schema change for it myself, if you want.
Comment 2 Michael[tm] Smith 2011-08-10 07:20:33 CEST
(In reply to comment #0)
> It appears that the validator always requires <link> to have a rel attribute.

As far as I can tell, it doesn't, actually. Do you have a test case where it's requiring a rel attribute on a link in the body of a document? (as opposed to the head)

I say that because, after examining the schema, I see that Henri's initial schema implementation actually anticipated this recent change that Hixie made -- in that Henri added a new link.elem.phrasing pattern to the schema, which is allowed only in the body and not in the head, and which does not allow the rel attribute, but which does require the itemprop attribute.

(The existing link.elem pattern remains unchanged -- it is only allowed in the head, and must have the rel attribute, and can't have the itemprop attribute.)

So, unless you have a document the demonstrates a test case in which the validator does not conform to the current spec, we should close this bug out.
Comment 3 Philip Jägenstedt 2011-08-10 10:35:43 CEST
<!DOCTYPE html>
<html itemscope>
<title></title>
<link itemprop="foo" href="bar">

Error: Element link is missing required attribute rel.

Apparently it's only in <head> that rel is required.

I'm happy for you (Michael) to fix both of these issues. Is it OK to have both in one bug?
Comment 4 Michael[tm] Smith 2011-08-10 10:38:35 CEST
(In reply to comment #3)
> <!DOCTYPE html>
> <html itemscope>
> <title></title>
> <link itemprop="foo" href="bar">
> 
> Error: Element link is missing required attribute rel.
> 
> Apparently it's only in <head> that rel is required.

But that link ends up in the head, right? Not in the body -

http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Chtml%20itemscope%3E%0A%3Ctitle%3E%3C%2Ftitle%3E%0A%3Clink%20itemprop%3D%22foo%22%20href%3D%22bar%22%3E%0A
Comment 5 Philip Jägenstedt 2011-08-10 10:40:28 CEST
(In reply to comment #4)
> (In reply to comment #3)
> > <!DOCTYPE html>
> > <html itemscope>
> > <title></title>
> > <link itemprop="foo" href="bar">
> > 
> > Error: Element link is missing required attribute rel.
> > 
> > Apparently it's only in <head> that rel is required.
> 
> But that link ends up in the head, right? Not in the body -
> 
> http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Chtml%20itemscope%3E%0A%3Ctitle%3E%3C%2Ftitle%3E%0A%3Clink%20itemprop%3D%22foo%22%20href%3D%22bar%22%3E%0A

Yes. rel shouldn't be required in <head> if there's an itemprop attribute, right?
Comment 6 Michael[tm] Smith 2011-08-10 10:45:42 CEST
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > <!DOCTYPE html>
> > > <html itemscope>
> > > <title></title>
> > > <link itemprop="foo" href="bar">
> > > 
> > > Error: Element link is missing required attribute rel.
> > > 
> > > Apparently it's only in <head> that rel is required.
> > 
> > But that link ends up in the head, right? Not in the body -
> > 
> > http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Chtml%20itemscope%3E%0A%3Ctitle%3E%3C%2Ftitle%3E%0A%3Clink%20itemprop%3D%22foo%22%20href%3D%22bar%22%3E%0A
> 
> Yes. rel shouldn't be required in <head> if there's an itemprop attribute,
> right?

ah, when I first read the current spec, I missed the part that says "When used with the itemprop attribute, the element can be used both in the head element and in the body of the page, subject to the constraints of the microdata model." (because Hixie has it in a NOTE...)

Anway, OK, now that I understand the actual requirements, I will make this change in the schema. I should be able to get it pretty quickly checked in and deployed at http://www.w3.org/html/check for testing. Will ping you as soon as I do
Comment 7 Michael[tm] Smith 2011-08-10 11:06:59 CEST
OK, I just pushed a change from my workspace to:

  http://www.w3.org/html/check

(In reply to comment #3)
> I'm happy for you (Michael) to fix both of these issues. Is it OK to have both
> in one bug?

Which two issues do you mean? The change I made just now was to make either itemprop or rel required on the <link> element in the head (previously, it had required just rel, and itemprop was optional).
Comment 8 Philip Jägenstedt 2011-08-10 13:49:19 CEST
(In reply to comment #7)
> OK, I just pushed a change from my workspace to:
> 
>   http://www.w3.org/html/check
> 
> (In reply to comment #3)
> > I'm happy for you (Michael) to fix both of these issues. Is it OK to have both
> > in one bug?
> 
> Which two issues do you mean? The change I made just now was to make either
> itemprop or rel required on the <link> element in the head (previously, it had
> required just rel, and itemprop was optional).

1. Disallowing both rel and itemprop on the same <link>

2. The incorrect error for missing rel on <link> in <head>

Both are likely fixed by the same changes.
Comment 9 Michael[tm] Smith 2011-08-10 14:01:17 CEST
(In reply to comment #8)
> 1. Disallowing both rel and itemprop on the same <link>
> 
> 2. The incorrect error for missing rel on <link> in <head>
> 
> Both are likely fixed by the same changes.

OK, yeah -- those should both be fixed by the change I made; you test case validates. Feel free to give it a try at http://www.w3.org/html/check when you have a chance. For now, I'll go ahead and push it upstream so we've also have it at validator.nu the next time Henri re-reploys.
Comment 10 Philip Jägenstedt 2011-08-10 14:16:32 CEST
Everything looks OK in my ad-hoc testing, thanks!
Comment 12 Michael[tm] Smith 2011-08-19 16:16:41 CEST
for the record here: I needed to make a refinement to the schema handling of the rel-or-itemprop constraint:

https://bitbucket.org/validator/syntax/changeset/35be31e29fc9

but it's just a schema-internal change; the effect on validation is exactly the same