If a HTML document is using namespaces, then it's safe to assume that the authoring software knows how to type the element names, so they shouldn't be changed.
This is affecting, for example, svg:clipPath
elements, which are turned into the unknown clippath
element, leading to processing errors further down the line.
Test case. Note that current browsers ignore the case, so even
clippath
works in a browser, but it fails validation and doesn't work in other tools.Attribute names shouldn't be altered as well, since
viewBox
gets changed toviewbox
, which is not a valid<svg>
attribute.Keeping element names from "foreign markup" is relatively simple. For attribute names its slightly less so as the transforms processor works on them before the tree is constructed and therefore we don't know whether an attribute should be lowercased or not until after transformation.
OK, I've figured out how to implement this and also pass all the existing tests. Its not wonderfully elegant but it does the trick.
Thank you Scott.