Skip to content

animint.js: remove unnecessary Selectors.hasOwnProperty checks#306

Open
ANAMASGARD wants to merge 8 commits into
masterfrom
Remove-Selectors-hasOwnProperty
Open

animint.js: remove unnecessary Selectors.hasOwnProperty checks#306
ANAMASGARD wants to merge 8 commits into
masterfrom
Remove-Selectors-hasOwnProperty

Conversation

@ANAMASGARD
Copy link
Copy Markdown
Contributor

@ANAMASGARD ANAMASGARD commented Mar 2, 2026

Fixes #278

  • Replaced Selectors.hasOwnProperty(selector_name) with a simple selector_name check in draw_geom and geom_label_aligned.
  • Removed redundant guard in update_selector.
  • Removed Selectors.hasOwnProperty check in update_axes.

I confirm I have not used any AI code generation tools for this PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.03%. Comparing base (a4220df) to head (3e7b176).

Files with missing lines Patch % Lines
inst/htmljs/animint.js 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #306   +/-   ##
=======================================
  Coverage   73.02%   73.03%           
=======================================
  Files         164      164           
  Lines        8837     8840    +3     
=======================================
+ Hits         6453     6456    +3     
  Misses       2384     2384           
Flag Coverage Δ
javascript 81.25% <88.88%> (+0.01%) ⬆️
r 69.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ANAMASGARD ANAMASGARD requested a review from tdhock March 2, 2026 14:00
Copy link
Copy Markdown
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also please investigate CI failure

Comment thread inst/htmljs/animint.js Outdated
Comment thread inst/htmljs/animint.js Outdated
Comment thread inst/htmljs/animint.js Outdated
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Sir @tdhock , if(selector_name) guards in Changes 1 and 2 cannot be removed safely — [selector_name] is null on initial geom rendering, so without the guards, Selectors[null].duration throws a TypeError and breaks all 149 JS tests.
The guards are not about checking hasOwnProperty on [Selectors]; they handle the case where no selector is active at all.
I removed them in previous commit which caused error , please give your feedback .

@ANAMASGARD ANAMASGARD requested a review from tdhock March 9, 2026 00:27
Copy link
Copy Markdown
Collaborator

@tdhock tdhock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revise

Comment thread inst/htmljs/animint.js Outdated
Comment thread inst/htmljs/animint.js Outdated
@tdhock
Copy link
Copy Markdown
Collaborator

tdhock commented Mar 10, 2026

ok i see now " [selector_name] is null on initial geom rendering" why and when does that happen?
i thought none of these blocks should run (and we can do no rendering) if we don’t have json info? (including selectors)

@ANAMASGARD ANAMASGARD requested review from suhaani-agarwal and tdhock and removed request for tdhock March 11, 2026 06:03
Fixes #278. Replaced Selectors.hasOwnProperty(selector_name) with a
simple selector_name check in draw_geom and geom_label_aligned.
Removed redundant guard in update_selector. Removed
Selectors.hasOwnProperty check in update_axes.
…e only

Replace bare if(selector_name) guards in geom_label_aligned and draw_geom
with if(selector_name && Selectors[selector_name].hasOwnProperty("duration"))
to match the same pattern already used in update_axes (Change 3).
@ANAMASGARD ANAMASGARD force-pushed the Remove-Selectors-hasOwnProperty branch from e766b51 to 008ab95 Compare May 29, 2026 01:05
Use selector_has_duration() for geom_label_aligned, draw_geom, and
update_axes so null selector_name on initial update_geom(g, null) stays
safe and we only transition when duration is defined. Remove redundant
hasOwnProperty guard in update_selector.
Comment thread DESCRIPTION Outdated
Comment thread inst/htmljs/animint.js Outdated
- DESCRIPTION: Gaurav comment -> GSOC 2026
- animint.js: drop git status and Selectors.hasOwnProperty; keep name guard for null selector_name on initial render
- NEWS.md: PR#306 attribution and accurate changelog wording
@ANAMASGARD
Copy link
Copy Markdown
Contributor Author

Sir @tdhock thanks for the review ,

  • !! removed — the function is only ever called inside if(...), so JavaScript already handles truthy/falsy correctly there. No need to force a boolean.

  • Selectors.hasOwnProperty(name) removed — agree with your point. If name is a real selector, it should already be in Selectors, so checking membership here is redundant.

  • name && kept — this one is actually necessary. During initial rendering, draw_geom and geom_label_aligned run for every geom, including ones that have no selector at all. For those, selector_name is null. If I remove the name && guard, Selectors[null] throws a TypeError and crashes all JS tests. I confirmed this in an earlier commit where removing it caused all 149 JS tests to fail.

@ANAMASGARD ANAMASGARD requested a review from tdhock May 29, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

animint.js Selectors does not need hasOwnProperty

2 participants