From 8f079e2d4566418afdfef16e594fc173423decc5 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Sun, 16 Oct 2022 17:27:46 +0100 Subject: [PATCH] Fix handling of orderedattributes when adding classes/styles Fixes issue referred to in https://github.com/Jermolene/TiddlyWiki5/pull/6877#issuecomment-1277590200 --- core/modules/utils/parsetree.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 5bab10706..a74b8f3f8 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -65,10 +65,8 @@ exports.addClassToParseTreeNode = function(node,classString) { // If the class attribute does not exist, we must create it first. attribute = {name: "class", type: "string", value: ""}; node.attributes["class"] = attribute; - if(node.orderedAttributes) { - // If there are orderedAttributes, we've got to add them there too. - node.orderedAttributes.push(attribute); - } + node.orderedAttributes = node.orderedAttributes || []; + node.orderedAttributes.push(attribute); } if(attribute.type === "string") { if(attribute.value !== "") { @@ -88,10 +86,8 @@ exports.addStyleToParseTreeNode = function(node,name,value) { if(!attribute) { attribute = {name: "style", type: "string", value: ""}; node.attributes.style = attribute; - if(node.orderedAttributes) { - // If there are orderedAttributes, we've got to add them there too. - node.orderedAttributes.push(attribute); - } + node.orderedAttributes = node.orderedAttributes || []; + node.orderedAttributes.push(attribute); } if(attribute.type === "string") { attribute.value += name + ":" + value + ";";