r92022 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92021‎ | r92022 | r92023 >
Date:23:44, 12 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added check to prevent adding duplicate annotations to content.
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Content.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Content.js
@@ -195,10 +195,23 @@
196196 for ( var i = start; i < end; i++ ) {
197197 switch ( annotation.method ) {
198198 case 'add':
 199+ var duplicate = false;
199200 if ( typeof this.data[i] === 'string' ) {
200201 this.data[i] = [this.data[i]];
 202+ } else {
 203+ for ( var j = 1; j < this.data[i].length; j++ ) {
 204+ if ( this.data[i][j].type === annotation.type
 205+ && Content.compareObjects(
 206+ this.data[i][j].data, annotation.data
 207+ )
 208+ ) {
 209+ duplicate = true;
 210+ }
 211+ }
201212 }
202 - this.data[i].push( annotation );
 213+ if ( !duplicate ) {
 214+ this.data[i].push( annotation );
 215+ }
203216 break;
204217 case 'remove':
205218 if ( typeof this.data[i] !== 'string' ) {

Status & tagging log