r101011 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101010‎ | r101011 | r101012 >
Date:17:59, 27 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Changed the order of operations in transaction processing for removing, updating node length MUST happen AFTER document data is changed because it emits updates to the UI.
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js (modified) (history)
  • /trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
@@ -668,7 +668,7 @@
669669 'rollback reverses the effect of a content annotation transaction on the content'
670670 );
671671
672 - var insertion = documentModel.prepareInsertion( 4, ['d'] );
 672+ var insertion = documentModel.prepareInsertion( 3, ['d'] );
673673
674674 // Test 5
675675 documentModel.commit( insertion );
@@ -678,8 +678,8 @@
679679 { 'type': 'paragraph' },
680680 'a',
681681 ['b', { 'type': 'bold', 'hash': '#bold' }],
 682+ 'd',
682683 ['c', { 'type': 'italic', 'hash': '#italic' }],
683 - 'd',
684684 { 'type': '/paragraph' }
685685 ],
686686 'commit applies an insertion transaction to the content'
@@ -691,8 +691,8 @@
692692 [
693693 'a',
694694 ['b', { 'type': 'bold', 'hash': '#bold' }],
695 - ['c', { 'type': 'italic', 'hash': '#italic' }],
696 - 'd'
 695+ 'd',
 696+ ['c', { 'type': 'italic', 'hash': '#italic' }]
697697 ],
698698 'commit keeps model tree up to date'
699699 );
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
@@ -114,7 +114,7 @@
115115 }
116116 this.cursor += op.data.length;
117117 }
118 -
 118+
119119 function remove( op ) {
120120 var elementLeft = es.DocumentModel.isElementOffset( this.data, this.cursor ),
121121 elementRight = es.DocumentModel.isElementOffset( this.cursor + op.data.length );
@@ -126,10 +126,10 @@
127127 } else {
128128 // Get the node we are removing content from
129129 var node = this.tree.getNodeFromOffset( this.cursor );
 130+ // Remove content from linear data model
 131+ this.data.splice( this.cursor, op.data.length );
130132 // Update model tree
131133 node.adjustContentLength( -op.data.length );
132 - // Remove content from linear data model
133 - this.data.splice( this.cursor, op.data.length );
134134 }
135135 }
136136 }

Status & tagging log