Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 61dac05

Browse files
committed
v3.3.1
1 parent a4c474e commit 61dac05

File tree

9 files changed

+93
-22
lines changed

9 files changed

+93
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change Log
22
==========
33

4+
## 3.3.1
5+
- Insures dataset uses polyfilled `Array.from` for old IE support.
6+
- Fixes support for sorting via element collection. This was not correctly implemented before although documented.
7+
- Fixes the "filter-by-url" demo to ensure that only leading `'.'` characters are stripped off rather than any character.
8+
49
## 3.3.0
510
- Introduces new internal filter hook `testResultEvaluateHideShown` allowing plugins to manipulate the result of every filter test upon a target. Provides an convenient entry point for non-selector based filtering such as range slider inputs.
611
- Adds range slider demo.

demos/filtering-by-url/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
function setHash(state) {
7171
var selector = state.activeFilter.selector;
72-
var newHash = '#' + selector.replace(/^./g, '');
72+
var newHash = '#' + selector.replace(/^\./g, '');
7373

7474
if (selector === targetSelector && window.location.hash) {
7575
// Equivalent to filter "all", remove the hash

demos/mixitup.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mixitup.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**!
2-
* MixItUp v3.3.0
2+
* MixItUp v3.3.1
33
* A high-performance, dependency-free library for animated filtering, sorting and more
4-
* Build 0be05511-2264-4384-8e31-c75554304cd0
4+
* Build 94e0fbf6-cd0b-4987-b3c0-14b59b67b8a0
55
*
66
* @copyright Copyright 2014-2018 KunkaLabs Limited.
77
* @author KunkaLabs Limited.
@@ -5766,7 +5766,11 @@
57665766
*/
57675767

57685768
sortOperation: function(operation) {
5769-
var self = this;
5769+
var self = this,
5770+
newOrder = [],
5771+
target = null,
5772+
el = null,
5773+
i = -1;
57705774

57715775
self.callActions('beforeSortOperation', arguments);
57725776

@@ -5775,7 +5779,23 @@
57755779
if (operation.newSort.collection) {
57765780
// Sort by collection
57775781

5778-
operation.newOrder = operation.newSort.collection;
5782+
newOrder = [];
5783+
5784+
for (i = 0; (el = operation.newSort.collection[i]); i++) {
5785+
if (self.dom.targets.indexOf(el) < 0) {
5786+
throw new Error(mixitup.messages.errorSortNonExistentElement());
5787+
}
5788+
5789+
target = new mixitup.Target();
5790+
5791+
target.init(el, self);
5792+
5793+
target.isInDom = true;
5794+
5795+
newOrder.push(target);
5796+
}
5797+
5798+
operation.newOrder = newOrder;
57795799
} else if (operation.newSort.order === 'random') {
57805800
// Sort random
57815801

@@ -7824,7 +7844,7 @@
78247844

78257845
insertDatasetFrag: function(frag, nextEl, targets) {
78267846
var self = this;
7827-
var insertAt = nextEl ? Array.from(self.dom.parent.children).indexOf(nextEl) : self.targets.length;
7847+
var insertAt = nextEl ? h.arrayFromList(self.dom.parent.children).indexOf(nextEl) : self.targets.length;
78287848

78297849
self.dom.parent.insertBefore(frag, nextEl);
78307850

@@ -10535,6 +10555,9 @@
1053510555
this.ERROR_DATASET_RENDERER_NOT_SET =
1053610556
'[MixItUp] To insert an element via the dataset API, a target renderer function must be provided to `render.target`';
1053710557

10558+
this.ERROR_SORT_NON_EXISTENT_ELEMENT =
10559+
'[MixItUp] An element to be sorted does not already exist in the container';
10560+
1053810561
/* Warnings
1053910562
----------------------------------------------------------------------------- */
1054010563

@@ -10655,5 +10678,5 @@
1065510678
mixitup.BaseStatic.call(mixitup.constructor);
1065610679

1065710680
mixitup.NAME = 'mixitup';
10658-
mixitup.CORE_VERSION = '3.3.0';
10681+
mixitup.CORE_VERSION = '3.3.1';
1065910682
})(window);

dist/mixitup.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mixitup",
33
"title": "MixItUp",
4-
"version": "3.3.0",
4+
"version": "3.3.1",
55
"description": "A high-performance, dependency-free library for animated filtering, sorting and more",
66
"author": "KunkaLabs Limited",
77
"homepage": "https://www.kunkalabs.com/mixitup/",

src/messages.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ mixitup.Messages = function() {
6060
this.ERROR_DATASET_RENDERER_NOT_SET =
6161
'[MixItUp] To insert an element via the dataset API, a target renderer function must be provided to `render.target`';
6262

63+
this.ERROR_SORT_NON_EXISTENT_ELEMENT =
64+
'[MixItUp] An element to be sorted does not already exist in the container';
65+
6366
/* Warnings
6467
----------------------------------------------------------------------------- */
6568

src/mixer.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,11 @@ h.extend(mixitup.Mixer.prototype,
838838
*/
839839

840840
sortOperation: function(operation) {
841-
var self = this;
841+
var self = this,
842+
newOrder = [],
843+
target = null,
844+
el = null,
845+
i = -1;
842846

843847
self.callActions('beforeSortOperation', arguments);
844848

@@ -847,7 +851,23 @@ h.extend(mixitup.Mixer.prototype,
847851
if (operation.newSort.collection) {
848852
// Sort by collection
849853

850-
operation.newOrder = operation.newSort.collection;
854+
newOrder = [];
855+
856+
for (i = 0; (el = operation.newSort.collection[i]); i++) {
857+
if (self.dom.targets.indexOf(el) < 0) {
858+
throw new Error(mixitup.messages.errorSortNonExistentElement());
859+
}
860+
861+
target = new mixitup.Target();
862+
863+
target.init(el, self);
864+
865+
target.isInDom = true;
866+
867+
newOrder.push(target);
868+
}
869+
870+
operation.newOrder = newOrder;
851871
} else if (operation.newSort.order === 'random') {
852872
// Sort random
853873

@@ -2896,7 +2916,7 @@ h.extend(mixitup.Mixer.prototype,
28962916

28972917
insertDatasetFrag: function(frag, nextEl, targets) {
28982918
var self = this;
2899-
var insertAt = nextEl ? Array.from(self.dom.parent.children).indexOf(nextEl) : self.targets.length;
2919+
var insertAt = nextEl ? h.arrayFromList(self.dom.parent.children).indexOf(nextEl) : self.targets.length;
29002920

29012921
self.dom.parent.insertBefore(frag, nextEl);
29022922

tests/unit/mixer-sort.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('mixitup.Mixer', () => {
6363

6464
after(() => mixer.destroy());
6565

66-
it('accept `default` as a sort string, but should have no effect on the order', () => {
66+
it('accepts `default` as a sort string, but should have no effect on the order', () => {
6767
var startOrder = mixer.getState().show;
6868

6969
return mixer.sort('default')
@@ -75,7 +75,7 @@ describe('mixitup.Mixer', () => {
7575
});
7676
});
7777

78-
it('accept `default:asc` as a sort string, but should have no effect on the order', () => {
78+
it('accepts `default:asc` as a sort string, but should have no effect on the order', () => {
7979
var startOrder = mixer.getState().show;
8080

8181
return mixer.sort('default:asc')
@@ -87,7 +87,7 @@ describe('mixitup.Mixer', () => {
8787
});
8888
});
8989

90-
it('accept `default:desc` as a sort string, which should reverse the order', () => {
90+
it('accepts `default:desc` as a sort string, which should reverse the order', () => {
9191
var reversedOrder = mixer.getState().show.slice().reverse();
9292

9393
return mixer.sort('default:desc')
@@ -184,6 +184,26 @@ describe('mixitup.Mixer', () => {
184184
});
185185
});
186186

187+
it('should accept a collection of elements by which to sort by', () => {
188+
const firstTarget = mixer.getState().targets[0];
189+
const collection = mixer.getState().targets.slice().reverse();
190+
191+
return mixer.sort(collection)
192+
.then(state => {
193+
const lastTarget = state.targets[state.targets.length - 1];
194+
195+
chai.assert.deepEqual(lastTarget, firstTarget);
196+
});
197+
});
198+
199+
it('should error if any element in the collection provided does not exist in the container', () => {
200+
const mixer = mixitup(container);
201+
202+
const collection = [document.createElement('div')];
203+
204+
chai.assert.throws(() => mixer.sort(collection));
205+
});
206+
187207
it('should accept a callback function which is invoked after sorting', () => {
188208
const promise = new Promise(resolve => mixer.sort('random', resolve));
189209

0 commit comments

Comments
 (0)