Bugzilla – Bug 842
srcdoc attribute on iframe in HTML5 does not validate
Last modified: 2011-06-16 12:08:45 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.)
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.
(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.
(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] ]]
https://bitbucket.org/validator/syntax/changeset/faf3698e1913 This will go live next time Henri re-deploys validator.nu.
(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.