Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the project-loading hook to make localStorage cache usage dependent on the active i18n locale, aiming to prevent incorrect cached content from being loaded after CCP locale switching.
Changes:
- Adds a locale match check (
cachedProject?._cachedLocale === i18n.language) before loading a cached project. - Simplifies the cache eligibility logic into a single
shouldUseCachecondition.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const raw = this.getAttribute(name); | ||
| if (raw != null) |
There was a problem hiding this comment.
Looking at examples of other custom components (such as the one here ) it looks like a common pattern is to use hasAttribute. The benefit of using this is we might be able to remove the (raw != null) check here and also the new if (rawValue == null || rawValue === "") return rawValue; check in parseAttribute (since there could be a reasons you might want to set an attribute to ""?). For example:
if (this.hasAttribute(name)) {
const raw = this.getAttribute(name);
fromDom[camelCase(name)] = this.parseAttribute(name, raw);
}
For my understanding, do you mean this disables the project caching when you change locale? Or is it more than that? |
Changes
Locale switching fix
useProjecthookInitial load problem fix
reactProps()ofweb-component.jsattributeChangedCallbackhasn't been run yet