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

Fixed globalize resource visitor and added the test #1756

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

tomasherceg
Copy link
Member

The GlobalizeResourceVisitor had a bug that sometimes did not correctly detect the need to add globalize JS resource.

When the first binding that requires globalize resource was detected, a boolean flag was set, but the RequiredResource control was being added when the visitor reached the end of a template property, or the end of a Content control, or the end of the entire view.

{{value: BindingWithGlobalizeRequirement}}
<dot:SomeControl>
  <SomeTemplate>
     <!-- the resource is added here -->
  </SomeTemplate>
</dot:SomeControl>

This was leading to a behavior when the resource was added into a random template which may not get into the page control tree eventually (e. g. when it is in AuthenticatedView or something like that).

I am not sure if the fix is good - I removed adding the resource in the templates, so it is added at the end of the Content or the view itself. Maybe it would be better to add it before or after the control which required the particular binding.

Copy link
Member

@exyi exyi left a comment

Choose a reason for hiding this comment

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

Good catch! The intent was to analyze the template separately to avoid adding resources in the (rare) case it's required only in an unused template. However, for that we'd need to nest the flags in the private void Visit<TNode> method. I guess it's not worth the effort/complexity...

@tomasherceg tomasherceg merged commit 955698c into main Jan 12, 2024
14 checks passed
@tomasherceg tomasherceg deleted the fix/globalize-auto-add branch January 12, 2024 13:06
exyi pushed a commit that referenced this pull request Jan 14, 2024
* Fixed globalize resource visitor and added the test

* Fixed unit tests - RequiredResource is added to a different place, changin the auto-generated ids of controls
@exyi exyi added this to the Version 4.2 milestone Jan 31, 2024
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.

2 participants