Skip to content

Commit

Permalink
First stab at fixing the aurelia-specific issue with the upstream dra…
Browse files Browse the repository at this point in the history
…gula. It's not awesome, but it does improve the situation.
  • Loading branch information
michaelmalonenz committed Mar 14, 2016
1 parent 907d956 commit 686bc63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var argv = require('yargs')
/**
* Add the files to test, always beginning with the source files!
*/
var filesToLoad = ['src/**/*.js', 'test/unit/initialize.spec.js'];
var filesToLoad = ['src/**/*.js', 'test/unit/initialize.spec.js', 'test/unit/lib/*.js'];
filesToLoad.push(path.join('test/unit/**', argv.t));

/**
Expand Down
5 changes: 3 additions & 2 deletions src/dragula.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export class Dragula {

this._source = context.source;
this._item = context.item;
this._initialSibling = this._currentSibling = Util.nextEl(context.item);
this._initialSibling = context.item.nextSibling;
this._currentSibling = Util.nextEl(context.item);

this.dragging = true;
this.emitter.emit('drag', this._item, this._source);
Expand Down Expand Up @@ -304,7 +305,7 @@ export class Dragula {
} else if (this._mirror) {
sibling = this._currentSibling;
} else {
sibling = Util.nextEl(this._copy || this._item);
sibling = (this._copy || this._item).nextSibling;
}
return target === this._source && sibling === this._initialSibling;
}
Expand Down
24 changes: 16 additions & 8 deletions test/unit/cancel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,28 @@ describe('cancelling a drag operation', function() {

it('returns the item to original position, including comment nodes', function() {
//arrange
let siblingInnerHtml = '<!--<view>--><div class="testDiv"></div><!--</view>-->'
let sibling = document.createElement('div');
sibling.innerHTML = siblingInnerHtml;
let container = document.createElement('div');

let testNode = document.createElement('div');
testNode.classList.add('testDiv');
let commentBegin = document.createComment('<view>');
let commentEnd = document.createComment('</view>');

container.appendChild(commentBegin);
container.appendChild(testNode);
container.appendChild(commentEnd);

document.body.appendChild(container);


let drake = new createDragula();
document.body.appendChild(sibling);
let item = sibling.querySelector('.testDiv');
expect(item).not.toBeNull();

//act
drake.manualStart(item);
drake.manualStart(testNode);
drake.cancel();

//assert
expect(sibling.innerHTML).toBe(siblingInnerHtml, 'nothing happens');
expect(commentBegin.nextSibling).toBe(testNode, 'nothing happens');
expect(drake.dragging).toBeFalsy('drake has stopped dragging');
});
});

0 comments on commit 686bc63

Please sign in to comment.