mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	Add utility method for getting ordered attributes
This commit is contained in:
		| @@ -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) { | ||||
| 	if(node.attributes && node.attributes[name] && node.attributes[name].value !== undefined) { | ||||
| 		return node.attributes[name].value; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jeremy@jermolene.com
					jeremy@jermolene.com