Browse Source

Merge branch 'dev' into dev

pull/1051/head
Lebedev Konstantin 7 years ago committed by GitHub
parent
commit
f1af267bff
  1. 18
      Gruntfile.js
  2. 25
      Sortable.js
  3. 2
      Sortable.min.js
  4. 10
      package.json
  5. 14
      test/e2e/index-page-model.js
  6. 22
      test/e2e/index.js

18
Gruntfile.js

@ -39,7 +39,20 @@ module.exports = function (grunt) {
}
},
jquery: {}
jquery: {},
testcafe: {
test: {
options: {
files: ['test/e2e/index.js'],
browsers: ['chrome'],
startApp: {
command: 'npm run http-server'
},
skipJsErrors: true //https://github.com/RubaXa/Sortable/issues/1041
}
}
}
});
@ -82,7 +95,8 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-testcafe');
grunt.registerTask('tests', ['jshint']);
grunt.registerTask('default', ['tests', 'version', 'uglify:dist']);
grunt.registerTask('default', ['tests', 'version', 'uglify:dist', 'testcafe']);
};

25
Sortable.js

@ -73,7 +73,7 @@
supportDraggable = !!('draggable' in document.createElement('div')),
supportCssPointerEvents = (function (el) {
// false when IE11
if (!!navigator.userAgent.match(/Trident.*rv[ :]?11\./)) {
if (!!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie)/i)) {
return false;
}
el = document.createElement('x');
@ -310,7 +310,7 @@
type = evt.type,
touch = evt.touches && evt.touches[0],
target = (touch || evt).target,
originalTarget = evt.target.shadowRoot && evt.path[0] || target,
originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0]) || target,
filter = options.filter,
startIndex;
@ -326,6 +326,10 @@
return; // only left button or enabled
}
// cancel dnd if original target is content editable
if (originalTarget.isContentEditable) {
return;
}
target = _closest(target, options.draggable, el);
@ -1421,12 +1425,15 @@
}
function _clone(el) {
return $
? $(el).clone(true)[0]
: (Polymer && Polymer.dom
? Polymer.dom(el).cloneNode(true)
: el.cloneNode(true)
);
if (Polymer && Polymer.dom) {
return Polymer.dom(el).cloneNode(true);
}
else if ($) {
return $(el).clone(true)[0];
}
else {
return el.cloneNode(true);
}
}
function _saveInputCheckedState(root) {
@ -1439,7 +1446,7 @@
}
}
// Fixed #973:
// Fixed #973:
_on(document, 'touchmove', function (evt) {
if (Sortable.active) {
evt.preventDefault();

2
Sortable.min.js vendored

File diff suppressed because one or more lines are too long

10
package.json

@ -4,15 +4,19 @@
"version": "1.5.1",
"devDependencies": {
"grunt": "*",
"grunt-version": "*",
"grunt-contrib-jshint": "*",
"grunt-contrib-uglify": "*"
"grunt-contrib-uglify": "*",
"grunt-testcafe": "^0.15.0",
"grunt-version": "*",
"http-server": "^0.9.0",
"testcafe": "^0.16.0"
},
"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.",
"main": "Sortable.js",
"scripts": {
"test": "./node_modules/grunt/bin/grunt",
"prepublish": "./node_modules/grunt/bin/grunt"
"prepublish": "./node_modules/grunt/bin/grunt",
"http-server": "http-server -s ./"
},
"repository": {
"type": "git",

14
test/e2e/index-page-model.js

@ -0,0 +1,14 @@
import { Selector } from 'testcafe';
export default class IndexPage {
constructor () {
const listAContainer = Selector('#foo');
const listAItems = listAContainer.find('li');
this.listA = {
container: listAContainer,
items: listAItems,
getItem: text => listAItems.withText(text)
};
}
}

22
test/e2e/index.js

@ -0,0 +1,22 @@
import IndexPage from './index-page-model';
const indexPage = new IndexPage();
fixture `Tests`
.page('http://localhost:8080/index.html');
test('List A', async t => {
const listA = indexPage.listA;
const firstItem = listA.items.nth(0);
const secondItem = listA.items.nth(1);
const hippoText = 'Бегемот';
const foodText = 'Корм';
await t
.expect(firstItem.innerText).eql(hippoText)
.expect(secondItem.innerText).eql(foodText)
.dragToElement(firstItem, secondItem, { speed: 0.5 })
.expect(firstItem.innerText).eql(foodText)
.expect(secondItem.innerText).eql(hippoText);
});
Loading…
Cancel
Save