Skip to content

Commit f1af267

Browse files
authored
Merge branch 'dev' into dev
2 parents 56c6965 + 1a89437 commit f1af267

File tree

6 files changed

+76
-15
lines changed

6 files changed

+76
-15
lines changed

Gruntfile.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,20 @@ module.exports = function (grunt) {
3939
}
4040
},
4141

42-
jquery: {}
42+
jquery: {},
43+
44+
testcafe: {
45+
test: {
46+
options: {
47+
files: ['test/e2e/index.js'],
48+
browsers: ['chrome'],
49+
startApp: {
50+
command: 'npm run http-server'
51+
},
52+
skipJsErrors: true //https://github.com/RubaXa/Sortable/issues/1041
53+
}
54+
}
55+
}
4356
});
4457

4558

@@ -82,7 +95,8 @@ module.exports = function (grunt) {
8295
grunt.loadNpmTasks('grunt-version');
8396
grunt.loadNpmTasks('grunt-contrib-jshint');
8497
grunt.loadNpmTasks('grunt-contrib-uglify');
98+
grunt.loadNpmTasks('grunt-testcafe');
8599

86100
grunt.registerTask('tests', ['jshint']);
87-
grunt.registerTask('default', ['tests', 'version', 'uglify:dist']);
101+
grunt.registerTask('default', ['tests', 'version', 'uglify:dist', 'testcafe']);
88102
};

Sortable.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
supportDraggable = !!('draggable' in document.createElement('div')),
7474
supportCssPointerEvents = (function (el) {
7575
// false when IE11
76-
if (!!navigator.userAgent.match(/Trident.*rv[ :]?11\./)) {
76+
if (!!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie)/i)) {
7777
return false;
7878
}
7979
el = document.createElement('x');
@@ -310,7 +310,7 @@
310310
type = evt.type,
311311
touch = evt.touches && evt.touches[0],
312312
target = (touch || evt).target,
313-
originalTarget = evt.target.shadowRoot && evt.path[0] || target,
313+
originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0]) || target,
314314
filter = options.filter,
315315
startIndex;
316316

@@ -326,6 +326,10 @@
326326
return; // only left button or enabled
327327
}
328328

329+
// cancel dnd if original target is content editable
330+
if (originalTarget.isContentEditable) {
331+
return;
332+
}
329333

330334
target = _closest(target, options.draggable, el);
331335

@@ -1421,12 +1425,15 @@
14211425
}
14221426

14231427
function _clone(el) {
1424-
return $
1425-
? $(el).clone(true)[0]
1426-
: (Polymer && Polymer.dom
1427-
? Polymer.dom(el).cloneNode(true)
1428-
: el.cloneNode(true)
1429-
);
1428+
if (Polymer && Polymer.dom) {
1429+
return Polymer.dom(el).cloneNode(true);
1430+
}
1431+
else if ($) {
1432+
return $(el).clone(true)[0];
1433+
}
1434+
else {
1435+
return el.cloneNode(true);
1436+
}
14301437
}
14311438

14321439
function _saveInputCheckedState(root) {
@@ -1439,7 +1446,7 @@
14391446
}
14401447
}
14411448

1442-
// Fixed #973:
1449+
// Fixed #973:
14431450
_on(document, 'touchmove', function (evt) {
14441451
if (Sortable.active) {
14451452
evt.preventDefault();

Sortable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"version": "1.5.1",
55
"devDependencies": {
66
"grunt": "*",
7-
"grunt-version": "*",
87
"grunt-contrib-jshint": "*",
9-
"grunt-contrib-uglify": "*"
8+
"grunt-contrib-uglify": "*",
9+
"grunt-testcafe": "^0.15.0",
10+
"grunt-version": "*",
11+
"http-server": "^0.9.0",
12+
"testcafe": "^0.16.0"
1013
},
1114
"description": "Minimalist JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery. Supports AngularJS and any CSS library, e.g. Bootstrap.",
1215
"main": "Sortable.js",
1316
"scripts": {
1417
"test": "./node_modules/grunt/bin/grunt",
15-
"prepublish": "./node_modules/grunt/bin/grunt"
18+
"prepublish": "./node_modules/grunt/bin/grunt",
19+
"http-server": "http-server -s ./"
1620
},
1721
"repository": {
1822
"type": "git",

test/e2e/index-page-model.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Selector } from 'testcafe';
2+
3+
export default class IndexPage {
4+
constructor () {
5+
const listAContainer = Selector('#foo');
6+
const listAItems = listAContainer.find('li');
7+
8+
this.listA = {
9+
container: listAContainer,
10+
items: listAItems,
11+
getItem: text => listAItems.withText(text)
12+
};
13+
}
14+
}

test/e2e/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import IndexPage from './index-page-model';
2+
3+
const indexPage = new IndexPage();
4+
5+
fixture `Tests`
6+
.page('http://localhost:8080/index.html');
7+
8+
test('List A', async t => {
9+
const listA = indexPage.listA;
10+
const firstItem = listA.items.nth(0);
11+
const secondItem = listA.items.nth(1);
12+
const hippoText = 'Бегемот';
13+
const foodText = 'Корм';
14+
15+
await t
16+
.expect(firstItem.innerText).eql(hippoText)
17+
.expect(secondItem.innerText).eql(foodText)
18+
.dragToElement(firstItem, secondItem, { speed: 0.5 })
19+
.expect(firstItem.innerText).eql(foodText)
20+
.expect(secondItem.innerText).eql(hippoText);
21+
});
22+

0 commit comments

Comments
 (0)