mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-03 01:10:45 +00:00
Fix addAttributeToParseTreeNode handling of ordered attributes
This commit is contained in:
parent
2ea0374b55
commit
0163c04b7d
@ -15,9 +15,18 @@ Parse tree utility functions.
|
|||||||
exports.addAttributeToParseTreeNode = function(node,name,value) {
|
exports.addAttributeToParseTreeNode = function(node,name,value) {
|
||||||
var attribute = {name: name, type: "string", value: value};
|
var attribute = {name: name, type: "string", value: value};
|
||||||
node.attributes = node.attributes || {};
|
node.attributes = node.attributes || {};
|
||||||
|
node.orderedAttributes = node.orderedAttributes || [];
|
||||||
node.attributes[name] = attribute;
|
node.attributes[name] = attribute;
|
||||||
if(node.orderedAttributes) {
|
var foundIndex = -1;
|
||||||
|
$tw.utils.each(node.orderedAttributes,function(attr,index) {
|
||||||
|
if(attr.name === name) {
|
||||||
|
foundIndex = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(foundIndex === -1) {
|
||||||
node.orderedAttributes.push(attribute);
|
node.orderedAttributes.push(attribute);
|
||||||
|
} else {
|
||||||
|
node.orderedAttributes[foundIndex] = attribute;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user