r91981 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91980‎ | r91981 | r91982 >
Date:18:01, 12 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Inserted text inherits annotations from neighboring characters from the left, unless it's being prepending, which causes them to be taken from the right
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Content.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Content.js
@@ -71,6 +71,17 @@
7272 };
7373
7474 Content.prototype.insert = function( start, insert ) {
 75+ // TODO: Prefer to not take annotations from a neighbor that's a space character
 76+ var neighbor = this.data[Math.max( start - 1, 0 )];
 77+ if ( $.isArray( neighbor ) ) {
 78+ var annotations = neighbor.slice( 1 );
 79+ for ( var i = 0; i < insert.length; i++ ) {
 80+ if ( typeof insert[i] === 'string' ) {
 81+ insert[i] = [insert[i]];
 82+ }
 83+ insert[i] = insert[i].concat( annotations );
 84+ }
 85+ }
7586 Array.prototype.splice.apply( this.data, [start, 0].concat( insert ) )
7687 };
7788

Status & tagging log