Ensure that it's safe to modify the DOM node pointers before doing so. Fixes #1224.
Add forgotten test for Element.attributes.