mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Add utility method for getting ordered attributes
This commit is contained in:
parent
bdd99edfe8
commit
0bffae2108
@ -21,6 +21,20 @@ exports.addAttributeToParseTreeNode = function(node,name,value) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.getOrderedAttributesFromParseTreeNode = function(node) {
|
||||||
|
if(node.orderedAttributes) {
|
||||||
|
return node.orderedAttributes;
|
||||||
|
} else {
|
||||||
|
var attributes = [];
|
||||||
|
$tw.utils.each(node.attributes,function(attribute) {
|
||||||
|
attributes.push(attribute);
|
||||||
|
});
|
||||||
|
return attributes.sort(function(a,b) {
|
||||||
|
return a.name < b.name ? -1 : (a.name > b.name ? 1 : 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
exports.getAttributeValueFromParseTreeNode = function(node,name,defaultValue) {
|
exports.getAttributeValueFromParseTreeNode = function(node,name,defaultValue) {
|
||||||
if(node.attributes && node.attributes[name] && node.attributes[name].value !== undefined) {
|
if(node.attributes && node.attributes[name] && node.attributes[name].value !== undefined) {
|
||||||
return node.attributes[name].value;
|
return node.attributes[name].value;
|
||||||
|
@ -48,7 +48,7 @@ LetWidget.prototype.computeAttributes = function() {
|
|||||||
var changedAttributes = {},
|
var changedAttributes = {},
|
||||||
self = this;
|
self = this;
|
||||||
this.currentValueFor = Object.create(null);
|
this.currentValueFor = Object.create(null);
|
||||||
$tw.utils.each(this.parseTreeNode.orderedAttributes,function(attribute,index) {
|
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) {
|
||||||
var value = self.computeAttribute(attribute),
|
var value = self.computeAttribute(attribute),
|
||||||
name = attribute.name;
|
name = attribute.name;
|
||||||
if(name.charAt(0) !== "$") {
|
if(name.charAt(0) !== "$") {
|
||||||
|
Loading…
Reference in New Issue
Block a user