Introduce NamedNodeMap for attributes. Clean up algorithms around attributes.

Fixes: https://www.w3.org/Bugs/Public/show_bug.cgi?id=21986
See also: https://www.w3.org/Bugs/Public/show_bug.cgi?id=25093 and
https://www.w3.org/Bugs/Public/show_bug.cgi?id=25016
Sorry about the noise from removing title attributes