RTC NPM Resource Changed bug PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
8 Jul 2024

Pull Request for Issue #43714 .

Summary of Changes

Use iife instead of esm for the scripts core and validate

Testing Instructions

  • Apply the PR
  • run npm install
  • Check that authenticating in the administrator works
  • Create a new article, don't add anything and press save, the validation error should appear
  • still in the article edit view, open the browser console, and type const initialize = 1; and hit Enter.

Before: Error SyntaxError: Identifier 'initialize' has already been declared
After: No error

Actual result BEFORE applying this Pull Request

Leaking variables in the global scope

Expected result AFTER applying this Pull Request

NO leaking variables in the global scope

Link to documentations

Please select:

  • [] Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@Fedik

be28f2d 8 Jul 2024 avatar dgrammatiko iife
avatar dgrammatiko dgrammatiko - open - 8 Jul 2024
avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Jul 2024
Category JavaScript Repository NPM Change
avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Title
[4.4][bugfix] Use life for the scripts core and validate
[4.4][bugfix] Use iife for the scripts core and validate
avatar dgrammatiko dgrammatiko - edited - 8 Jul 2024
avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Labels Added: NPM Resource Changed PR-4.4-dev
avatar Fedik
Fedik - comment - 8 Jul 2024

thanks! I will test it later

avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
Labels Added: bug
avatar Fedik
Fedik - comment - 8 Jul 2024

hmhm, nope, sorry, it does not work. The variables in the file still globally available.
'use strict' just forcing developer to use var, const, let, and some other litle things.

It should be anonymous function wrapper.
But it is not possible, because we have import punycode from 'punycode'; (this will throw rollup/babel compilation error).

Need to hack the rollup/babel somehow ?
I have no other ideas.

avatar Fedik
Fedik - comment - 8 Jul 2024

No, Ignore me ?

avatar Fedik
Fedik - comment - 8 Jul 2024

It works, but, wee need to set some globals back. please add:

window.JFormValidator = JFormValidator;
window.punycode = punycode;

Someone may use it in their scripts, even though punycode not officially shipped.
Maybe with some comment, that it will be removed in future.

avatar dgrammatiko
dgrammatiko - comment - 8 Jul 2024

Classes exposed to the global scope

avatar Fedik Fedik - test_item - 8 Jul 2024 - Tested successfully
avatar Fedik
Fedik - comment - 8 Jul 2024

I have tested this item ✅ successfully on 348daed


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43755.

avatar Fedik
Fedik - comment - 8 Jul 2024

For testing.
Open Article editing, open browser console, and type const initialize = 1; and hit Enter.

Before:
Error SyntaxError: Identifier 'initialize' has already been declared
After:
No error;

avatar dgrammatiko dgrammatiko - change - 8 Jul 2024
The description was changed
avatar dgrammatiko dgrammatiko - edited - 8 Jul 2024
avatar Quy Quy - test_item - 17 Jul 2024 - Tested successfully
avatar Quy
Quy - comment - 17 Jul 2024

I have tested this item ✅ successfully on 348daed


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43755.

avatar Quy Quy - change - 17 Jul 2024
Status Pending Ready to Commit
avatar Quy
Quy - comment - 17 Jul 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/43755.

avatar MacJoom MacJoom - change - 1 Aug 2024
Labels Added: RTC
avatar MacJoom MacJoom - change - 1 Aug 2024
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-08-01 22:15:17
Closed_By MacJoom
avatar MacJoom MacJoom - close - 1 Aug 2024
avatar MacJoom MacJoom - merge - 1 Aug 2024
avatar MacJoom
MacJoom - comment - 1 Aug 2024

Thank you!

Add a Comment

Login with GitHub to post a comment