1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-11 18:00:26 +00:00

Fix: allow overwrite plugin that don't have plugin-priority (#8800)

* fix: allow overwrite plugin that don't have plugin-priority

* Update boot.js

* Update boot.js
This commit is contained in:
lin onetwo 2024-12-05 20:37:37 +08:00 committed by GitHub
parent 42b2b9fd20
commit 673a0f5605
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1470,17 +1470,15 @@ $tw.Wiki = function(options) {
// Unpack the currently registered plugins, creating shadow tiddlers for their constituent tiddlers // Unpack the currently registered plugins, creating shadow tiddlers for their constituent tiddlers
this.unpackPluginTiddlers = function() { this.unpackPluginTiddlers = function() {
var self = this; var self = this;
// Sort the plugin titles by the `plugin-priority` field // Sort the plugin titles by the `plugin-priority` field, if this field is missing, default to 1
pluginTiddlers.sort(function(a,b) { pluginTiddlers.sort(function(a, b) {
if("plugin-priority" in a.fields && "plugin-priority" in b.fields) { var priorityA = "plugin-priority" in a.fields ? a.fields["plugin-priority"] : 1;
return a.fields["plugin-priority"] - b.fields["plugin-priority"]; var priorityB = "plugin-priority" in b.fields ? b.fields["plugin-priority"] : 1;
} else if("plugin-priority" in a.fields) { if (priorityA !== priorityB) {
return priorityA - priorityB;
} else if (a.fields.title < b.fields.title) {
return -1; return -1;
} else if("plugin-priority" in b.fields) { } else if (a.fields.title === b.fields.title) {
return +1;
} else if(a.fields.title < b.fields.title) {
return -1;
} else if(a.fields.title === b.fields.title) {
return 0; return 0;
} else { } else {
return +1; return +1;