Fix #8335: Avoid memory leak by never setting data on non-element non-document nodes. Ref gh-1127.
(cherry picked from commit cc324abf739669bd2a4669742c994b86c4ad467b)
Ref 8f72967e: use acceptData to determine when it is safe to add event handlers
(cherry picked from commit 50290b8ffb05c504d3866a619f282bf795bc01f6)