From 2d1f0131136f3d3f1e588c9c03705904f5a16c32 Mon Sep 17 00:00:00 2001 From: Minha Date: Tue, 22 Oct 2024 13:54:43 -0400 Subject: [PATCH 1/3] Explicitly make sure element has both binding and ix attributes before continuing --- .../apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js b/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js index d8e762b3346b..cff1187fac4d 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js @@ -705,7 +705,8 @@ hqDefine("cloudcare/js/form_entry/form_ui", [ } } }; - if (!_.isEmpty(element) && allChildren && allChildren.length > 0) { + if (element.hasOwnProperty('binding') && element.hasOwnProperty('ix') && allChildren && + allChildren.length > 0) { findChildAndSetFilename(allChildren); } From 870dfe1bf9f4a7c21783b9746ee852bf878886b0 Mon Sep 17 00:00:00 2001 From: Minha Date: Tue, 22 Oct 2024 15:56:25 -0400 Subject: [PATCH 2/3] Lint fix --- .../apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js b/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js index cff1187fac4d..11ea8daf1c78 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js @@ -705,8 +705,8 @@ hqDefine("cloudcare/js/form_entry/form_ui", [ } } }; - if (element.hasOwnProperty('binding') && element.hasOwnProperty('ix') && allChildren && - allChildren.length > 0) { + if (Object.prototype.hasOwnProperty.call(element, 'binding') && + Object.prototype.hasOwnProperty.call(element, 'ix') && allChildren && allChildren.length > 0) { findChildAndSetFilename(allChildren); } From 2c136aee5e746579d50829395fe3f26a749fa5e1 Mon Sep 17 00:00:00 2001 From: Minha Date: Wed, 23 Oct 2024 12:02:36 -0400 Subject: [PATCH 3/3] Refactor using underscore.js --- .../apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js b/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js index 11ea8daf1c78..f56878277474 100644 --- a/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js +++ b/corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js @@ -705,8 +705,7 @@ hqDefine("cloudcare/js/form_entry/form_ui", [ } } }; - if (Object.prototype.hasOwnProperty.call(element, 'binding') && - Object.prototype.hasOwnProperty.call(element, 'ix') && allChildren && allChildren.length > 0) { + if (_.has(element, 'binding') && _.has(element, 'ix') && !_.isEmpty(allChildren)) { findChildAndSetFilename(allChildren); }