Skip to content

Commit

Permalink
Возникала ошибка метода State#destroy, если в данных состояния находи…
Browse files Browse the repository at this point in the history
…лся очищенный объект State.
  • Loading branch information
Vladislav Kurkin committed Dec 2, 2016
1 parent 073b7d6 commit fa5970f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ State.prototype.invoke = function (fnc, args, context) {
* @returns {State}
*/
State.prototype.destroy = function (recursive) {
if (recursive === true) {
if (recursive === true && this.stateData) {
destroyItems(this.stateData);
}

Expand Down Expand Up @@ -1007,7 +1007,6 @@ function Queue(items, start) {
.onState(STATE_RESOLVED, this.stop)
.onState(STATE_REJECTED, this.stop);


if (typeof start === 'boolean' && start) {
this.start();
}
Expand Down Expand Up @@ -1110,7 +1109,7 @@ Queue.prototype.item = null;
Queue.prototype.context = null;

/**
* @param {Array} args - аргументы для первой задачи
* @param {Array} [args] - аргументы для первой задачи
* @returns {Queue}
*/
Queue.prototype.start = function (args) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Response",
"author": "Vladislav Kurkin <[email protected]> (https://github.com/B-Vladi)",
"version": "0.1.8",
"version": "0.1.9",
"main": "Response.js",
"license": "MIT",
"repository": {
Expand Down
6 changes: 6 additions & 0 deletions spec/State.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,12 @@ describe('State:', function () {
}
});

it('destroy with an empty State object don`t throw exception', function () {
state
.setState(1, [new State().destroy()])
.destroy(true);
});

describe('invoke', function () {
it('without arguments', function () {
state.invoke(listener);
Expand Down

0 comments on commit fa5970f

Please sign in to comment.