Skip to content

Commit 174347f

Browse files
dgrammatikolaoneo
andauthored
[5.3] [bugfix] Use iife for the scripts core and load validate as module (joomla#43758)
* iife * fixes * nope * nope * cs * Update validate.es6.js * CS * CS * oops * what * cs * cs * x * fix --------- Co-authored-by: Allon Moritz <[email protected]>
1 parent 97381a6 commit 174347f

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

build/build-modules-js/javascript/compile-to-es2017.mjs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ import { babel } from '@rollup/plugin-babel';
1010
import { minifyCode } from './minify.mjs';
1111
import { getPackagesUnderScope } from '../init/common/resolve-package.cjs';
1212

13-
function esmOrIife(file) {
14-
if (file.endsWith('core.es6.js') || file.endsWith('validate.es6.js')) {
15-
return 'iife';
16-
}
17-
return 'es';
18-
}
19-
2013
// List of external modules that should not be resolved by rollup
2114
const externalModules = [];
2215
const collectExternals = () => {
@@ -91,7 +84,7 @@ export const handleESMFile = async (file) => {
9184
});
9285

9386
bundle.write({
94-
format: esmOrIife(file),
87+
format: file.endsWith('core.es6.js') ? 'iife' : 'es',
9588
sourcemap: false,
9689
file: resolve(`${newPath}.js`),
9790
})

build/media_source/system/joomla.asset.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
"type": "script",
174174
"class": "FormValidateAssetItem",
175175
"attributes": {
176-
"defer": true
176+
"type": "module"
177177
},
178178
"dependencies": [
179179
"core"

build/media_source/system/js/fields/validate.es6.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
33
* @license GNU General Public License version 2 or later; see LICENSE.txt
44
*/
5-
6-
'use strict';
7-
85
import punycode from 'punycode';
96

107
class JFormValidator {
@@ -317,14 +314,7 @@ class JFormValidator {
317314
}
318315
}
319316

320-
const initialize = () => {
321-
document.formvalidator = new JFormValidator();
322-
323-
// Cleanup
324-
document.removeEventListener('DOMContentLoaded', initialize);
325-
};
326-
327-
document.addEventListener('DOMContentLoaded', initialize);
317+
document.formvalidator = new JFormValidator();
328318

329319
/**
330320
* Expose the classes to the global scope

0 commit comments

Comments
 (0)