Fix ElementWrapper.toJSON().

The prior implementation appeared to be a stub. It didn't use a callback
function which caused problems. The new unit test 'v(id) with single id then toJSON'
failed with the prior implementation, but succeeds with the new implementation,
which is modeled directly after PipelineWrapper.toJSON.