Fixed case on mapping to $.toJSON

* Also made uses of JSON.stringify use ve.getHash

Change-Id: I05dc0374e05b72c798ae0fd44239e5f8bb45ca52
This commit is contained in:
Trevor Parscal 2012-05-21 12:20:35 -07:00
parent 272f502693
commit c38a552442
2 changed files with 6 additions and 2 deletions

View file

@ -199,7 +199,7 @@ ve.dm.HTMLConverter.generateAnnotatedContent = function( content, annotations )
if ( annotations[i].data !== undefined && Object.keys(annotations[i].data).length === 0 ) {
delete annotations[i].data;
}
annoationMap[JSON.stringify( annotations[i] )] = annotations[i];
annoationMap[ve.getHash( annotations[i] )] = annotations[i];
}
for ( i = 0; i < characters.length; i++ ) {
characters[i] = [characters[i], annoationMap];

View file

@ -68,12 +68,16 @@ ve.inArray = $.inArray;
*
* This is actually an alias for jQuery.json, which falls back to window.JSON if present.
*
* WARNING: 2 objects can have the same contents but not the same hash if the properties were set
* in a different order. Recursive sorting may nessecary prior to hashing, or a hashing algorithm
* that produces order-safe reults may need to be used here instead.
*
* @static
* @method
* @param {Object} obj Object to generate hash for
* @returns {String} Hash of object
*/
ve.getHash = $.toJson;
ve.getHash = $.toJSON;
/**
* Gets an array of all property names in an object.