From 762de81444fcdeffa383124915b32e8e17250ab6 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sat, 8 Jan 2022 16:18:04 +0000 Subject: [PATCH] Refine fix to retain stylesheet ordering The order of tiddlers in the HTML file uses localeCompare(), and that determines the insertion order. So if we want to be compatible with older versions we have to use localeCompare() to order tiddlers, not a plain sort() --- boot/boot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 6b8c50255..0afb5149d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -75,10 +75,10 @@ $tw.utils.insertSortedArray = function(array,value) { var low = 0, high = array.length - 1, mid, cmp; while(low <= high) { mid = (low + high) >> 1; - cmp = array[mid]; - if(value > cmp) { + cmp = value.localeCompare(array[mid]); + if(cmp > 0) { low = mid + 1; - } else if(value < cmp) { + } else if(cmp < 0) { high = mid - 1; } else { return array; @@ -1101,7 +1101,7 @@ $tw.Wiki = function(options) { tiddlerTitles = null, // Array of tiddler titles getTiddlerTitles = function() { if(!tiddlerTitles) { - tiddlerTitles = Object.keys(tiddlers).sort(); + tiddlerTitles = Object.keys(tiddlers).sort(function(a,b) {return a.localeCompare(b);}); } return tiddlerTitles; },