Skip to content

fix: Treat asset ID zero as a valid reference - #10183

Open
Daytonrad wants to merge 1 commit into
playcanvas:mainfrom
Daytonrad:fix/asset-reference-zero-id
Open

Daytonrad wants to merge 1 commit into
playcanvas:mainfrom
Daytonrad:fix/asset-reference-zero-id

Conversation

@Daytonrad

Copy link
Copy Markdown

Description

AssetRegistry accepts numeric ID 0, and assigning it to AssetReference.id can resolve an existing asset, but the reference's truthiness checks skip event binding and unbinding. A zero-ID reference misses add/load/remove/unload callbacks, and incorrectly permits a URL to be selected at the same time.

Check for null or undefined instead of truthiness when testing whether an ID is selected. No API additions.

Validation

  • Three new regressions fail before the fix and pass afterward. They cover late registration, an existing zero-ID asset, lifecycle callbacks, clearing the reference, and ID/URL exclusivity.
  • npm test: 5,040 passing, 65 pending.
  • Repository-wide lint and all seven build targets pass.
  • git diff --check passes.

Tests use the real registry and in-memory JSON assets in the existing Node/JSDOM harness. No GPU rendering was exercised.

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

This branch has not been deployed

No deployments
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.

1 participant