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

Critical errors on global.js script in old browser (<=2021) caused by # usage for private fields on SectionId class #3583

Open
uPesyLabs opened this issue Aug 13, 2024 · 0 comments

Comments

@uPesyLabs
Copy link

uPesyLabs commented Aug 13, 2024

Describe the current behavior

On old browser, there is an error in global.js that prevent the script to be loaded successfully.
image

Since it's a critical JS, with some functions used by other scripts, some other webcomponents doesn't work either.

Describe the expected behavior

No error when loading the global.js script.

Version information (Dawn, browsers and operating systems)

  • Dawn Version: 15.0.1
  • iOS, v14.1 / Chrome Mobile 92.0.4515.90

Possible solution

Apparently it's caused by this new Class :

dawn/assets/global.js

Lines 9 to 26 in a22f8de

class SectionId {
static #separator = '__';
// for a qualified section id (e.g. 'template--22224696705326__main'), return just the section id (e.g. 'template--22224696705326')
static parseId(qualifiedSectionId) {
return qualifiedSectionId.split(SectionId.#separator)[0];
}
// for a qualified section id (e.g. 'template--22224696705326__main'), return just the section name (e.g. 'main')
static parseSectionName(qualifiedSectionId) {
return qualifiedSectionId.split(SectionId.#separator)[1];
}
// for a section id (e.g. 'template--22224696705326') and a section name (e.g. 'recommended-products'), return a qualified section id (e.g. 'template--22224696705326__recommended-products')
static getIdForSection(sectionId, sectionName) {
return `${sectionId}${SectionId.#separator}${sectionName}`;
}
}

The fix is : Don't use this new feature of private field with #. Can be hardcoded directly or use a const instead.
You can check the browser compatibility here : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties#browser_compatibility

Additional context/screenshots

On Chrome Mobile 92.0.4515.90 on iPhone 12 (from Browserstack)
image

@uPesyLabs uPesyLabs changed the title Critical errors on global.js script in old browser (<=2021) caused by # usage for private fields on SectionId class Critical errors on global.js script in old browser (<=2021) caused by # usage for private fields on SectionId class Aug 13, 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

No branches or pull requests

1 participant