Fix getDocument() for views that emit values

A view could e.g. emit a scalar or an object with other data – still
getDocument() should return the associated document