oerpub/github-bookeditor — pull request #165 by izak (2014-02-18 14:16:54+00:00)
Title: Fix namespace error message

The problem snuck in after I fixed the double-body problem some time ago. By using the innerHTML of the body instead of serializing the body, I ended up with a xmlns on every top level element inside the body.

When you hit enter in Aloha, it makes a copy of whatever element it's in. It also copies all the attributes. It didn't like copying xmlns, hence the error message.

This fixes the problem using somewhat of a sledgehammer approach. It parses the body/head out using regex. Normally that's a bad idea for html, but here we use fresh html from XMLSerializer, so it should be safe.