As a workaround you can just redeclare the color without closing the subject tag.
Indeed it is a bug if we consider that it is said that compatibility with HTML is preserved, by which we may assume the syntax is XML like as in XHTML your example should be valid and the workaround above is invalid.
But right now the behaviour does not follow an XML logic of opening and closing tags enclosing effected text.