Parsing HTML for editing purposes is quite different from parsing it by the book. VS HTML parser has a quite a few deviations that allow us to better support statement completion and validation. Look at this bug which we usually see every release since VS 2002 (that’s when the code was added). Consider the following markup:
<a b=”c” d=”e”>
User positions caret right after “c”, hits backspace twice and invokes statement compeltion for attribute b by hitting Ctrl+Space. The markup looks now like
<a b=” d=”e”>
If we parse by the book and consider ” d=” to be a value for b, statement competion will then replace ” d=” by the new value, significantly damaging user code. Since this is much more common editing scenario that having sequence
at the end of the attribute value, we give it higher priority.
The issue ofny manifests itself when attribute value ends with an equal sign or with an equal sign followed by a whitespace. <a b=”c=d“> actually works fine. The workaround is either to avoid trailing = (try to use : instead) or encode = as an entity: =
We are looking into building a better parser in the future, of course.