Use ownerDocument
instead of document
#1158
Merged
ownerDocument
instead of document
#1158