In ve.ui.MWReferenceDialog, this.referenceSurface changed from being a Surface to a SurfaceWidget. I noticed this because I rebased some old code that used this.referenceSurface.getModel() and broke, but this seems to have happened a while ago with the introduction of SurfaceWidget.
When a variable name is 'fooSurface', it should be a Surface, not something else. In particular, you shouldn't have to do this.referenceSurface.getSurface() to get the surface.
The same applies to this.captionSurface in ve.ui.MWMediaEditDialog.