Rejecting nodes other than element and document in acceptData to avoid memory leak. Fixes #8335