maqetta/maqetta — Issue #1821: Remove `withDoc` from CommandStack
Author: jhpedemonte
Created: 2012-02-29 18:00:03+00:00
State: open
Labels: Priority Med, Runtime

**CommandStack** contains the following code in its `execute()` function (around line 24):

```javascript
if (this._context && (this._context.declaredClass != 'davinci.themeEditor.Context' && this._context.declaredClass != 'davinci.ve.themeEditor.Context'))
// changing doc root causes problems with Style palette
dojo.withDoc(this._context.getDocument(), "execute", command,[this._context]);
else
command.execute();
```

First, not sure why there are **two different paths** here.

Most importantly, we **shouldn't be using `withDoc`** here. This means that, when using Dojo calls, **all commands work within the context of the VE iframe**.

But this isn't necessary. All the commands work within both the app and the VE contexts. Instead, we should move the `withDoc` invocations down into the commands themselves -- that code will know better whether it needs to work within the VE context.

@JonFerraiolo @peller