From 0f9444fa06031e7d8e3c1ad36e701090e0b17ec1 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 2 Sep 2024 16:24:09 +0200 Subject: [PATCH] LibJS: Fix mix-up when re-exporting an imported symbol with a new name This makes https://cling.com/ load, and more of the animated elements on https://shopify.com/ start appearing. --- Tests/LibWeb/Text/expected/js-export-rename.txt | 1 + Tests/LibWeb/Text/input/js-export-rename-helper.js | 2 ++ Tests/LibWeb/Text/input/js-export-rename-module.js | 2 ++ Tests/LibWeb/Text/input/js-export-rename.html | 13 +++++++++++++ Userland/Libraries/LibJS/SourceTextModule.cpp | 2 +- 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/js-export-rename.txt create mode 100644 Tests/LibWeb/Text/input/js-export-rename-helper.js create mode 100644 Tests/LibWeb/Text/input/js-export-rename-module.js create mode 100644 Tests/LibWeb/Text/input/js-export-rename.html diff --git a/Tests/LibWeb/Text/expected/js-export-rename.txt b/Tests/LibWeb/Text/expected/js-export-rename.txt new file mode 100644 index 00000000000..a3bd33744bd --- /dev/null +++ b/Tests/LibWeb/Text/expected/js-export-rename.txt @@ -0,0 +1 @@ +PASS: 123 diff --git a/Tests/LibWeb/Text/input/js-export-rename-helper.js b/Tests/LibWeb/Text/input/js-export-rename-helper.js new file mode 100644 index 00000000000..08c35054a2c --- /dev/null +++ b/Tests/LibWeb/Text/input/js-export-rename-helper.js @@ -0,0 +1,2 @@ +var value = 123; +export { value }; diff --git a/Tests/LibWeb/Text/input/js-export-rename-module.js b/Tests/LibWeb/Text/input/js-export-rename-module.js new file mode 100644 index 00000000000..c59d52ea04b --- /dev/null +++ b/Tests/LibWeb/Text/input/js-export-rename-module.js @@ -0,0 +1,2 @@ +import { value } from "./js-export-rename-helper.js"; +export { value as renamedValue }; diff --git a/Tests/LibWeb/Text/input/js-export-rename.html b/Tests/LibWeb/Text/input/js-export-rename.html new file mode 100644 index 00000000000..f753053b39e --- /dev/null +++ b/Tests/LibWeb/Text/input/js-export-rename.html @@ -0,0 +1,13 @@ + + + + diff --git a/Userland/Libraries/LibJS/SourceTextModule.cpp b/Userland/Libraries/LibJS/SourceTextModule.cpp index b50c671ca21..d8850f89ad7 100644 --- a/Userland/Libraries/LibJS/SourceTextModule.cpp +++ b/Userland/Libraries/LibJS/SourceTextModule.cpp @@ -217,7 +217,7 @@ Result, Vector> SourceTextModule::pa else { // a. NOTE: This is a re-export of a single name. // b. Append the ExportEntry Record { [[ModuleRequest]]: ie.[[ModuleRequest]], [[ImportName]]: ie.[[ImportName]], [[LocalName]]: null, [[ExportName]]: ee.[[ExportName]] } to indirectExportEntries. - indirect_export_entries.empend(ExportEntry::indirect_export_entry(import_entry.module_request(), import_entry.import_name, export_entry.export_name)); + indirect_export_entries.empend(ExportEntry::indirect_export_entry(import_entry.module_request(), export_entry.export_name, import_entry.import_name)); } } }