From d809dc7e3720a8cb30a0e4d181dfb9a7cf8d7aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inez=20Korczyn=CC=81ski?= Date: Thu, 18 Apr 2013 13:39:56 -0700 Subject: [PATCH] Added inline comment explaining not obvious purpose of code Change-Id: Ib9ea1307ebe58c03abd00dcf8b96681d6901a3d4 --- modules/ve/ce/ve.ce.ContentBranchNode.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/ve/ce/ve.ce.ContentBranchNode.js b/modules/ve/ce/ve.ce.ContentBranchNode.js index 674f825a85..f5cb3d4015 100644 --- a/modules/ve/ce/ve.ce.ContentBranchNode.js +++ b/modules/ve/ce/ve.ce.ContentBranchNode.js @@ -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.

123456

) 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;