That Fiddle show a new error. However, if you switch back to 3.8, that error goes away.
The problem for the code is around the event used to trigger the creation of the digit. The code used 'layer-add-result', which is an event that fired multiple times, thus the developer was actually trying to create many instances of TOC and would running into problems. Even developer code just called 'addLayer' once, the basemap add by API itself would trigger that event internally too. Having something like "if (toc==null ) toc=new ..." might help, although it is really about make sure knowing when the code will be called. Why 3.8 worked could be just how DOJO internally check div changed, may not even an ESRI thing.