From 7d57fdbbc4f14924eb796f5218d63aef5a01e0d0 Mon Sep 17 00:00:00 2001 From: harshiittttt Date: Mon, 15 Dec 2025 22:43:23 +0530 Subject: [PATCH 1/6] animint.js: remove unnecessary hasOwnProperty selector checks --- inst/htmljs/animint.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 04c21430..750f2223 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1567,7 +1567,7 @@ var animint = function (to_select, json_file) { eActions = function(groups) { // Handle transitions seperately due to unique structure of geom_label_aligned var transitionDuration = 0; - if (Selectors.hasOwnProperty(selector_name)) { + if (Selectors[selector_name]) { transitionDuration = +Selectors[selector_name].duration || 0; } groups.each(function(d) { @@ -1863,7 +1863,7 @@ var animint = function (to_select, json_file) { positionTooltip(tooltip, tooltip.html()); }); } - if(Selectors.hasOwnProperty(selector_name)){ + if(Selectors[selector_name]){ var milliseconds = Selectors[selector_name].duration; elements = elements.transition().duration(milliseconds); } @@ -2084,7 +2084,7 @@ var animint = function (to_select, json_file) { } var update_selector = function (v_name, value) { - if(!Selectors.hasOwnProperty(v_name)){ + if(!Selectors[v_name]){ return; } value = value + ""; From ad7e8bbfac10fc927d80b8f0e10c5cae550c5b3a Mon Sep 17 00:00:00 2001 From: harshiittttt Date: Tue, 16 Dec 2025 00:45:26 +0530 Subject: [PATCH 2/6] did required changes --- inst/htmljs/animint.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 750f2223..a8a880e7 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -2084,9 +2084,6 @@ var animint = function (to_select, json_file) { } var update_selector = function (v_name, value) { - if(!Selectors[v_name]){ - return; - } value = value + ""; var s_info = Selectors[v_name]; if(s_info.type == "single"){ From 59b2dd39ff89ec3cfb60eb1e560b9a4c1914d9d5 Mon Sep 17 00:00:00 2001 From: harshiittttt Date: Tue, 16 Dec 2025 22:21:29 +0530 Subject: [PATCH 3/6] Added contributor, changed version and updated news --- DESCRIPTION | 7 +++++-- NEWS.md | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cdd8e0a3..66db83e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: animint2 Title: Animated Interactive Grammar of Graphics -Version: 2025.12.3 +Version: 2025.12.4 URL: https://animint.github.io/animint2 BugReports: https://github.com/animint/animint2/issues Authors@R: c( @@ -64,7 +64,10 @@ Authors@R: c( comment="Animint2 GSoC 2025"), person("Gaurav", "Chaudhary", role="ctb", - comment="Remove unused css.file parameter; fix issue #233 selector values; fix issue #273 update_axes tick font-size")) + comment="Remove unused css.file parameter; fix issue #233 selector values; fix issue #273 update_axes tick font-size"), + person("Harshit","Gangwar", + role="ctb", + comment="Removed unnecessary hasOwnProperty checks in animint.js; fix issue #278 animint.js Selectors does not need hasOwnProperty checks")) Description: Functions are provided for defining animated, interactive data visualizations in R code, and rendering on a web page. The 2018 Journal of Computational and diff --git a/NEWS.md b/NEWS.md index ec55e63d..beaaff19 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Changes in version 2025.12.4 (PR#284) + +- issue #278 Removed unnecessary hasOwnProperty selector checks in `animint.js`. + # Changes in version 2025.12.3 (PR#282) - URL hash handling: Removed old `window.location.hash` parsing code from `animint.js` (issue #280). From c0e1f05e41a9045e7e1a68e562a51ca671512d95 Mon Sep 17 00:00:00 2001 From: harshiittttt Date: Tue, 16 Dec 2025 23:00:29 +0530 Subject: [PATCH 4/6] removed all selector checks --- inst/htmljs/animint.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index a8a880e7..249f3528 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1567,9 +1567,7 @@ var animint = function (to_select, json_file) { eActions = function(groups) { // Handle transitions seperately due to unique structure of geom_label_aligned var transitionDuration = 0; - if (Selectors[selector_name]) { - transitionDuration = +Selectors[selector_name].duration || 0; - } + transitionDuration = +Selectors[selector_name].duration || 0; groups.each(function(d) { var group = d3.select(this); // Select existing elements (if any) @@ -1863,10 +1861,8 @@ var animint = function (to_select, json_file) { positionTooltip(tooltip, tooltip.html()); }); } - if(Selectors[selector_name]){ - var milliseconds = Selectors[selector_name].duration; - elements = elements.transition().duration(milliseconds); - } + var milliseconds = Selectors[selector_name].duration; + elements = elements.transition().duration(milliseconds); if(g_info.aes.hasOwnProperty("id")){ elements.attr("id", get_attr("id")); } From bb015d63d128cad8f1e930011e1de6cf6ee25e83 Mon Sep 17 00:00:00 2001 From: harshiittttt Date: Wed, 17 Dec 2025 03:18:39 +0530 Subject: [PATCH 5/6] removed + --- inst/htmljs/animint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 249f3528..8a1382a6 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1567,7 +1567,7 @@ var animint = function (to_select, json_file) { eActions = function(groups) { // Handle transitions seperately due to unique structure of geom_label_aligned var transitionDuration = 0; - transitionDuration = +Selectors[selector_name].duration || 0; + transitionDuration = Selectors[selector_name].duration || 0; groups.each(function(d) { var group = d3.select(this); // Select existing elements (if any) From 1e7041889e2f5cf21367b3ad62dad9e183d5a488 Mon Sep 17 00:00:00 2001 From: Gauarv Chaudhary Date: Sat, 3 Jan 2026 19:11:21 +0530 Subject: [PATCH 6/6] fix: Remove unnecessary hasOwnProperty checks in animint.js Removed all Selectors.hasOwnProperty checks and added proper defensive checks to prevent undefined selector access errors. Changes: - Line ~1570: Added if-check before accessing selector duration - Line ~1866: Added if-check for transition duration - Line ~2084: Added early return if selector doesn't exist - Line ~2534-2536: Removed hasOwnProperty for clickSelects and legend checks All hasOwnProperty checks removed while maintaining safety through defensive programming. Fixes #278 Co-authored-by: Harshit Gangwar --- DESCRIPTION | 2 +- inst/htmljs/animint.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 66db83e0..e2c3bfae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -64,7 +64,7 @@ Authors@R: c( comment="Animint2 GSoC 2025"), person("Gaurav", "Chaudhary", role="ctb", - comment="Remove unused css.file parameter; fix issue #233 selector values; fix issue #273 update_axes tick font-size"), + comment="Remove unused css.file parameter; fix issue #233 selector values; fix issue #273 update_axes tick font-size; Collaborated on fixing issue #278 hasOwnProperty checks in animint.js"), person("Harshit","Gangwar", role="ctb", comment="Removed unnecessary hasOwnProperty checks in animint.js; fix issue #278 animint.js Selectors does not need hasOwnProperty checks")) diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 8a1382a6..a01e8b3a 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -1567,7 +1567,9 @@ var animint = function (to_select, json_file) { eActions = function(groups) { // Handle transitions seperately due to unique structure of geom_label_aligned var transitionDuration = 0; - transitionDuration = Selectors[selector_name].duration || 0; + if(Selectors[selector_name]){ + transitionDuration = Selectors[selector_name].duration || 0; + } groups.each(function(d) { var group = d3.select(this); // Select existing elements (if any) @@ -1861,8 +1863,10 @@ var animint = function (to_select, json_file) { positionTooltip(tooltip, tooltip.html()); }); } - var milliseconds = Selectors[selector_name].duration; - elements = elements.transition().duration(milliseconds); + if(Selectors[selector_name]){ + var milliseconds = Selectors[selector_name].duration; + elements = elements.transition().duration(milliseconds); + } if(g_info.aes.hasOwnProperty("id")){ elements.attr("id", get_attr("id")); } @@ -2080,8 +2084,11 @@ var animint = function (to_select, json_file) { } var update_selector = function (v_name, value) { - value = value + ""; var s_info = Selectors[v_name]; + if(!s_info){ + return; + } + value = value + ""; if(s_info.type == "single"){ // value is the new selection. s_info.selected = value; @@ -2524,9 +2531,9 @@ var animint = function (to_select, json_file) { var selector_widgets_hidden = show_hide_selector_widgets.text() == toggle_message; var has_no_clickSelects = - !Selectors[s_name].hasOwnProperty("clickSelects") + !Selectors[s_name].clickSelects var has_no_legend = - !Selectors[s_name].hasOwnProperty("legend") + !Selectors[s_name].legend if(selector_widgets_hidden && has_no_clickSelects && has_no_legend){ var node = show_hide_selector_widgets.node(); show_or_hide_fun.apply(node);