Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't cache parsed value of selector(All) property types #5521

Merged
merged 1 commit into from May 3, 2024

Conversation

mrxz
Copy link
Contributor

@mrxz mrxz commented May 2, 2024

Description:
This PR addresses a small regression introduced with #5474. The selector and selectorAll property types have a parse function that can be considered impure, i.e. the output depends on more than just the value being parsed. The current state of the DOM at the time of parsing factors in as well.

#5474 shifted the moment properties were parsed and cached in case of entities that hadn't loaded yet. This works fine as long as the selector can already match the relevant entities at that time. @arpu ran into a situation where a small HTML template was constructed in full before being inserted into the scene. These could contain selectors that would refer to elements in the same snippet. For illustration, consider the following snippet being constructed dynamically post scene-load:

<a-entity>
    <a-entity id="target"></a-entity>
    <a-entity component-with-selector="target: #target"></a-entity>
</a-entity>

To resolve this, the PR adds a isCacheable property to the property types which signals if the parsed value may be cached or not. This prevents the selector/selectorAll property types from being prematurely parsed and cached, better matching the old behaviour.

@arpu Could you verify that this solves the issue for you?

Changes proposed:

  • Add isCacheable flag to property types selector and selectorAll
  • Don't cache the parsed result in case a property isn't cacheable

@arpu
Copy link
Contributor

arpu commented May 2, 2024

i can confirm this fixed the problem to update vrland.io codebase to latest aframe master ( all tests a passed)

@dmarcos
Copy link
Member

dmarcos commented May 3, 2024

Thank you!

@dmarcos dmarcos merged commit 9fe641c into aframevr:master May 3, 2024
1 check passed
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.

None yet

3 participants