http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99489

Revision: 99489
Author:   catrope
Date:     2011-10-11 16:15:17 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
Merge duplicate code from r99452 and r99487 (communication snafu between me and 
Neil) and add another test for prepareRemoval()

Modified Paths:
--------------
    trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
    trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js

Modified: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
===================================================================
--- trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js   2011-10-11 
16:14:47 UTC (rev 99488)
+++ trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js   2011-10-11 
16:15:17 UTC (rev 99489)
@@ -597,16 +597,12 @@
        tx.pushRemove( removed );
        
        // Retain up to the end of the document
-       tx.pushRetain( this.data.length - range.end );
-       
-       range.normalize();
-
-       if ( range.start > 0 ) {
-               tx.pushRetain( range.start );
+       if ( range.end < this.data.length ) {
+               tx.pushRetain( this.data.length - range.end );
        }
-
-       var i = range.start;
-               removeData = [];
+       
+       /*
+        * Loop to detect structural changes:
        while ( i < range.end ) {
                var data = this.data[i];
                if ( data.type !== undefined ) {
@@ -617,7 +613,7 @@
                }
                i++;
        }
-       tx.pushRemove( removeData );
+       */
 
        /*
         * // Structural changes
@@ -634,9 +630,7 @@
                i++;
        }
        */
-       if ( range.end < this.data.length ) {
-               tx.pushRetain( this.data.length - range.end );
-       }
+       
        return tx;
 };
 

Modified: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
===================================================================
--- trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js   2011-10-11 
16:14:47 UTC (rev 99488)
+++ trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js   2011-10-11 
16:15:17 UTC (rev 99489)
@@ -357,6 +357,23 @@
        );
        
        deepEqual(
+               documentModel.prepareRemoval( new es.Range( 15, 18 ) ),
+               [
+                       { 'type': 'retain', 'length': 15 },
+                       {
+                               'type': 'remove',
+                               'data': [
+                                       { 'type': 'listItem', 'attributes': { 
'styles': ['bullet', 'bullet'] } },
+                                       'b',
+                                       { 'type': '/listItem' }
+                               ]
+                       },
+                       { 'type': 'retain', 'length': 10 }
+               ],
+               'prepareRemoval removes entire elements'
+       );
+       
+       deepEqual(
                documentModel.prepareInsertion( 1, ['d', 'e', 'f'] ),
                [
                        { 'type': 'retain', 'length': 1 },


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to