Added inline comment explaining not obvious purpose of code

Change-Id: Ib9ea1307ebe58c03abd00dcf8b96681d6901a3d4
This commit is contained in:
Inez Korczyński 2013-04-18 13:39:56 -07:00
parent d54cf4c131
commit d809dc7e37

View file

@ -24,6 +24,13 @@ ve.ce.ContentBranchNode = function VeCeContentBranchNode( model, $element ) {
var lastTransaction;
// Events
// Main purpose of code below is to increase performance by ensuring that renderContents() is
// called exactly once after transaction is processed. Case when childUpdate event is received
// multiple times is for instance when entire paragraph with multiple nodes inside it
// (e.g. <p>123<alien></alien>456</p>) is being annotated.
// Keeping reference to transaction object in view may look like anti pattern - however please
// have in mind that this transaction here is not being used in any other way than just as
// a flag to figure out if renderContents should be executed or not.
this.on( 'childUpdate', ve.bind( function( transaction ) {
if ( lastTransaction !== transaction ) {
lastTransaction = transaction;