HTML5 Validation in Visual Studio 2010 - script still requires type tag?
I am validating against HTML5 obtained through VS2010 SP1. I was under the impression that this simplification was possible:
<script type="text/javascript" src="foo.js">...</script>
to
<script src="foo.js">...</script>
In attempting this, I found:
<head id="Head1" runat="server">
<script src="../Scripts/MicrosoftAjax.js"></script>
</head>
yielded this:
Warning 1 Validation开发者_StackOverflow中文版 (HTML5): Element 'script' is missing required attribute 'type'.
Am I missing something? Is the Visual Studio XHTML5 validation more strict than the HTML5 doc necessitates?
I resolved the issue by manually editing the schema file.
<xsd:element name="script">
...
<xsd:attribute name="type" vs:readonly="true" use="required">
...
- Close all instances of Visual Studio 2010
- Open a text editor as a user with administrative rights
- Open the file
html_5.xsd
in the VS schemas folder
<Program Files>\Microsoft Visual Studio 10.0\Common7\Packages\schemas\html
- On line 617 (within the
xsd:element name="script"
tag) remove theuse="required"
attribute. - Save the file.
- Reopen Visual Studio 2010
Seems like it's been submitted to Connect. The VS validator is being stricter than the HTML5
spec.
The file is in the \Program Files(x86)\ directory on 64-bit Windows.
I have found a better solution. I installed official plugin for Visual Studio 2008 and 2010 from MSDN named HTML 5 Intellisense for Visual Studio 2010 and 2008
. It's for coding with HTML5.
You can view the details and download here: http://visualstudiogallery.msdn.microsoft.com/d771cbc8-d60a-40b0-a1d8-f19fc393127d
After installing, your validator should have a new option, choose HTML5, and VS will produce warnings no more.
I installed the HTML 5 Intellisense plugin, but I still had to edit the html5.xsd file to make it go away.
精彩评论