Avoid fetches for empty feature IDs#82
Open
schalkneethling wants to merge 1 commit into
Open
Conversation
Author
|
Heya @devnook - I was referred to you by @captainbrosset to ping for review here. I would also be more than happy to help with the process of triaging issues, managing dependency updates, etc., so let me know if there is a way to do this. Thanks! |
Contributor
|
@atopal are you, or someone who worked on this codebase in the past, able to review this PR please? I've looked at it a bit, but would be more comfortable if someone who's worked on this could review. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #80 by preventing
<baseline-status>from requesting WebStatus API URLs when the feature id is missing, empty, or whitespace-only.What changed
trim()so values like" "are treated as empty.feature-idattribute alias tofeatureIdinwillUpdate()instead ofupdated().@lit/taskfetch path so falsy normalized ids return before callingfetch().feature-id, dynamicfeature-idupdates, and clearingfeature-id.Why
willUpdate()Lit already handles
attributeChangedCallback()for reactive properties, so this PR does not override it.The alias sync belongs in
willUpdate()because it computes state needed by the upcoming update. This also lets@lit/tasksee the normalizedfeatureIdbefore it checks its args and decides whether to run.The previous
updated()sync happened after render, and could schedule a second update. Moving the sync earlier keeps the behavior in Lit's normal lifecycle.Test notes
The negative fetch tests use
aTimeout(0)afterupdateCompleteto give any asyncTaskrun attempt a chance to happen before asserting that no request was made.The dynamic positive cases use
waitUntil()to wait for the observable fetch count to stabilize rather than relying on a particular browser tick.Validation
npx eslint baseline-status.js test/baseline-status.test.jsPATH=/Users/schalkneethling/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH npm testAll 11 browser tests pass.