Skip to content

Commit

Permalink
[BUGFIX #484] Improve NestedTransaction handling
Browse files Browse the repository at this point in the history
* ensure running `commit` always clears the current transaction
* if we begin a transaction with an existing transaction warn, commit it, then start begin the next.
  • Loading branch information
stefanpenner committed May 25, 2017
1 parent 414f9be commit a6c3c94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/@glimmer/runtime/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ export abstract class Environment {
}

begin() {
assert(!this._transaction, 'Cannot start a nested transaction');
let transaction = this._transaction;
assert(!transaction, 'a glimmer transaction was begun, but one already exists. You may have a nested transaction');
this._transaction = new Transaction();
}

Expand Down Expand Up @@ -359,8 +360,9 @@ export abstract class Environment {
}

commit() {
this.transaction.commit();
let transaction = this.transaction;
this._transaction = null;
transaction.commit();
}

attributeFor(element: Simple.Element, attr: string, isTrusting: boolean, namespace?: string): AttributeManager {
Expand Down

0 comments on commit a6c3c94

Please sign in to comment.