https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103480

Revision: 103480
Author:   tparscal
Date:     2011-11-17 18:11:48 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Addressed some issues identified in review of r103447 - this could be cleaner, 
but it's trying to be optimized so the UI doesn't flicker during a 
remove/insert (such as splitting a block)

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js

Modified: trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js 
2011-11-17 18:05:14 UTC (rev 103479)
+++ trunk/extensions/VisualEditor/modules/es/es.TransactionProcessor.js 
2011-11-17 18:11:48 UTC (rev 103480)
@@ -101,9 +101,16 @@
                        remove = oldNodes.length;
                }
        }
-       parent.splice.apply(
-               parent, [index, remove].concat( 
es.DocumentModel.createNodesFromData( newData ) )
-       );
+       // Try to perform this in a single operation if possible, this reduces 
the number of UI updates
+       // TODO: Introduce a global for max argument length - 1024 is also 
assumed in es.insertIntoArray
+       var newNodes = es.DocumentModel.createNodesFromData( newData );
+       if ( newNodes.length < 1024 ) {
+               parent.splice.apply( parent, [index, remove].concat( newNodes ) 
);
+       } else {
+               parent.splice.apply( parent, [index, remove] );
+               // Safe to call with arbitrary length of newNodes
+               es.insertIntoArray( parent, index, newNodes );
+       }
 };
 
 es.TransactionProcessor.prototype.getScope = function( node, data ) {


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

Reply via email to