From: Aleksander Ɓukasz Date: Wed, 18 Dec 2013 11:22:45 +0000 (+0100) Subject: wlxml: lists fix X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/dc8e2e1f8da0f76030d4a4d3c2acf432c9896779 wlxml: lists fix The default sort order used by Array.prototype.sort is lexicographic. This broke node selection for include/exclude for/from a list. --- diff --git a/src/wlxml/extensions/list/list.js b/src/wlxml/extensions/list/list.js index 6d7b251..99cacb1 100644 --- a/src/wlxml/extensions/list/list.js +++ b/src/wlxml/extensions/list/list.js @@ -35,7 +35,7 @@ extension.document.transformations.createList = { /* globals Node */ var parent = params.node1.parent(), parentContents = parent.contents(), - nodeIndexes = [params.node1.getIndex(), params.node2.getIndex()].sort(), + nodeIndexes = [params.node1.getIndex(), params.node2.getIndex()].sort(function(a,b) { return a-b; }), nodesToWrap = [], listNode = params.node1.document.createDocumentNode({tagName: 'div', attrs: {'class': 'list'}}), node, i; @@ -78,7 +78,7 @@ extension.document.transformations.extractItems = { impl: function(params) { params = _.extend({}, {merge: true}, params); var list = params.item1.parent(), - indexes = [params.item1.getIndex(), params.item2.getIndex()].sort(), + indexes = [params.item1.getIndex(), params.item2.getIndex()].sort(function(a,b) { return a-b;}), precedingItems = [], extractedItems = [], succeedingItems = [],