http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99452
Revision: 99452
Author: neilk
Date: 2011-10-11 00:24:44 +0000 (Tue, 11 Oct 2011)
Log Message:
-----------
make prepareRemoval test pass (naively -- will add better test next)
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
00:14:48 UTC (rev 99451)
+++ trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js 2011-10-11
00:24:44 UTC (rev 99452)
@@ -583,6 +583,26 @@
*/
es.DocumentModel.prototype.prepareRemoval = function( range ) {
var tx = new es.Transaction();
+ range.normalize();
+
+ if ( range.start > 0 ) {
+ tx.pushRetain( range.start );
+ }
+
+ var i = range.start;
+ removeData = [];
+ while ( i < range.end ) {
+ var data = this.data[i];
+ if ( data.type !== undefined ) {
+ console.log( "later" );
+ // TODO structural
+ } else {
+ removeData.push( this.data[i] );
+ }
+ i++;
+ }
+ tx.pushRemove( removeData );
+
/*
* // Structural changes
* if ( The range spans structural elements ) {
@@ -594,7 +614,13 @@
* } else {
* Removing only content is OK, do nothing
* }
- */
+ /
+ 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
00:14:48 UTC (rev 99451)
+++ trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js 2011-10-11
00:24:44 UTC (rev 99452)
@@ -351,7 +351,7 @@
['c', { 'type': 'italic', 'hash':
'#italic' }]
]
},
- { 'type': 'retain', 'length': 25 }
+ { 'type': 'retain', 'length': 24 }
],
'prepareRemoval includes the content being removed'
);
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs