NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 842 - srcdoc attribute on iframe in HTML5 does not validate
srcdoc attribute on iframe in HTML5 does not validate
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: HTML5 schema
HEAD
All All
: P2 normal
Assigned To: Michael[tm] Smith
http://bertilow.com/div/srcdoc/srcdoc...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-15 11:47 CEST by Bertil Wennergren
Modified: 2011-06-16 12:08 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 Bertil Wennergren 2011-06-15 11:47:55 CEST
As far as I can tell the test page at "http://bertilow.com/div/srcdoc/srcdoc.html" is valid HTML5. It uses the srcdoc attribute on an iframe element. The validator however claims that that is not allowed. I cannot see how that can be.

(I do understand that practical use of srcdoc is not realistic at this point. This is just a question of formal validity.)
Comment 1 Michael[tm] Smith 2011-06-15 14:20:46 CEST
Yeah, the schema is not yet in conformance with the spec for srcdoc. The problem is that what the spec requires as the value of the srcdoc attribute would necessitate having the validator code run the contents of the src attribute through either an error-reporting HTML parser or an XML parser -- depending on what the content type of the document is. I think that's doable and I will chat with Henri and try to add it myself (unless Henri gets to it first). But for the time being, I guess we could just make srcdoc valid in the schema and just allow its value to be any string. That will prevent the error message from being for now, and adding the parsing of the actual value can probably wait til if/when support for srcdoc actually gets implemented in browsers.
Comment 2 Bertil Wennergren 2011-06-15 17:15:10 CEST
(In reply to comment #1)

> Yeah, the schema is not yet in conformance with the spec for srcdoc. The
> problem is that what the spec requires as the value of the srcdoc attribute
> would necessitate having the validator code run the contents of the src
> attribute through either an error-reporting HTML parser or an XML parser --
> depending on what the content type of the document is. I think that's doable
> and I will chat with Henri and try to add it myself (unless Henri gets to it
> first).

Would that even be correct? I'm no expert, but it seems to me that the
the value of the srcdoc attribute ist just a string, as far as validity
of the document goes. That string will fill an iframe with _a different
doc_ just as a src attribute does. Including the document loaded with
src in the validation of the parent doc would certainly be an error. I
believe the same goes for a doc created with srcdoc. Content included
in src with a data URI is another such case.

> But for the time being, I guess we could just make srcdoc valid in the
> schema and just allow its value to be any string. That will prevent the error
> message from being for now, and adding the parsing of the actual value can
> probably wait til if/when support for srcdoc actually gets implemented in
> browsers.

I think that's the right thing to do.
Comment 3 Michael[tm] Smith 2011-06-16 05:09:57 CEST
(In reply to comment #2)
> (In reply to comment #1)
> 
> > Yeah, the schema is not yet in conformance with the spec for srcdoc. The
> > problem is that what the spec requires as the value of the srcdoc attribute
> > would necessitate having the validator code run the contents of the src
> > attribute through either an error-reporting HTML parser or an XML parser --
> > depending on what the content type of the document is. I think that's doable
> > and I will chat with Henri and try to add it myself (unless Henri gets to it
> > first).
> 
> Would that even be correct? I'm no expert, but it seems to me that the
> the value of the srcdoc attribute ist just a string, as far as validity
> of the document goes.

The spec says this:

http://dev.w3.org/html5/spec/the-iframe-element.html#attr-iframe-src
[[
For iframe elements in HTML documents, the attribute, if present, must have a value using the HTML syntax that consists of the following syntactic components, in the given order:

1. Any number of comments and space characters.
2. Optionally, a DOCTYPE.
3. Any number of comments and space characters.
4. The root element, in the form of an html element.
5. Any number of comments and space characters.

For iframe elements in XML documents, the attribute, if present, must have a value that matches the production labeled document in the XML specification. [XML]
]]
Comment 4 Michael[tm] Smith 2011-06-16 11:48:15 CEST
https://bitbucket.org/validator/syntax/changeset/faf3698e1913

This will go live next time Henri re-deploys validator.nu.
Comment 5 Bertil Wennergren 2011-06-16 12:08:45 CEST
(In reply to comment #3)

> The spec says this:
> 
> http://dev.w3.org/html5/spec/the-iframe-element.html#attr-iframe-src
> [[
> For iframe elements in HTML documents, the attribute, if present, must have a
> value using the HTML syntax that consists of the following syntactic
> components, in the given order: [...]

You're right, of course.

A warning should probably be shown if srcdoc is used, until
such checks are in place.