Don't compare annotations directly with ve.compare()

Annotations' attributes might contain DOM elements, which cause infinite
recursion in ve.compare(). Annotation classes can protect against this
by overriding getHashObject() to summarize DOM nodes, but that doesn't
help if that's not respected everywhere.

Instead, compare the hash objects, those are safe. This does not appear
to be a problem in practice, currently, because the nowiki annotation
is experimental, oo.compare() now short-circuits if a === b, and because
of optimizations in openAndCloseAnnotations() which lead to the relevant
compareToForSerialization() code path being taken very rarely.

Bug: 51948
Change-Id: If1bcc3eee4fd14d107db1935d89dcc5516643b53
This commit is contained in:
Roan Kattouw 2013-07-26 16:42:31 -07:00 committed by Catrope
parent fe40b86e74
commit 83e1888275

View file

@ -165,7 +165,7 @@ ve.dm.Annotation.prototype.isGenerated = function () {
ve.dm.Annotation.prototype.compareToForSerialization = function ( annotation ) {
// If both annotations were generated
if ( this.isGenerated() && annotation.isGenerated() ) {
return ve.compare( this, annotation );
return ve.compare( this.getHashObject(), annotation.getHashObject() );
}
return ve.compare(