From 8ef1c75aa1f1ca0b677d9a32f38afb3f8dbad142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 25 Mar 2019 16:29:09 +0100 Subject: [PATCH] fix(react2angular): Fixed react to angular wrapper watching function expressions causing infinte digest loop, fixes #16194 (#16196) --- public/app/core/services/ng_react.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/app/core/services/ng_react.ts b/public/app/core/services/ng_react.ts index 5292b924925..ed51dd81a92 100644 --- a/public/app/core/services/ng_react.ts +++ b/public/app/core/services/ng_react.ts @@ -110,20 +110,23 @@ function watchProps(watchDepth, scope, watchExpressions, listener) { const watchGroupExpressions = []; - watchExpressions.forEach(expr => { + for (const expr of watchExpressions) { const actualExpr = getPropExpression(expr); const exprWatchDepth = getPropWatchDepth(watchDepth, expr); + // ignore empty expressions & expressions with functions + if (!actualExpr || actualExpr.match(/\(.*\)/) || exprWatchDepth === 'one-time') { + continue; + } + if (exprWatchDepth === 'collection' && supportsWatchCollection) { scope.$watchCollection(actualExpr, listener); } else if (exprWatchDepth === 'reference' && supportsWatchGroup) { watchGroupExpressions.push(actualExpr); - } else if (exprWatchDepth === 'one-time') { - //do nothing because we handle our one time bindings after this } else { scope.$watch(actualExpr, listener, exprWatchDepth !== 'reference'); } - }); + } if (watchDepth === 'one-time') { listener();