From 38fd32413d2ada5f1ee954bf412f3628368f26a0 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 21 Oct 2018 23:14:47 +0200 Subject: [PATCH] diff: add some comments --- src/browser/js/app/editor/diff.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/browser/js/app/editor/diff.js b/src/browser/js/app/editor/diff.js index e762e21a..050f279c 100644 --- a/src/browser/js/app/editor/diff.js +++ b/src/browser/js/app/editor/diff.js @@ -4,6 +4,9 @@ module.exports = { diffToWidget: function(widget, diff) { + // traverse a diff patch and the associated widget + // to return the first node (widget and sub-patch) with actual changes + var children = diff.tabs ||diff.widgets if (children) { @@ -14,10 +17,10 @@ module.exports = { if ( !children || - Array.isArray(children) || - deletedChildren.length || - changedChildren.length !== 1 || - Array.isArray(children[changedChildren[0]]) + Array.isArray(children) || // 'tabs' or 'widgets' property created + deletedChildren.length || // 'tabs' or 'widgets' property created + changedChildren.length !== 1 || // children reordered (or same property edited in multiple widgets, but case ignored) + Array.isArray(children[changedChildren[0]]) // child item created ) { return [widget, diff] }