User tests: Successful: Unsuccessful:
Convert unnamed function
to arrow function
follow #38154
Status | New | ⇒ | Pending |
Category | ⇒ | JavaScript Repository NPM Change |
I have tested this item
Warning from eslint is fixed.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
NPM Resource Changed
?
Maintainers Checked
|
RTC
Although this PR cleans up the warning there are more problems in this file, eg the addEventListener('DOMContentLoaded', ...)
is an ANTIPATTERN and should be removed (the file is either loaded with attribute defer or type=module which render the waiting for the DOM to be ready useless). I had fixed it correctly with #38225: https://github.com/joomla/joomla-cms/pull/38225/files#diff-4afb4f910136391957e62b8afcb5f0d6b240ee226cd69b4960777bc15ddfe668
The code should be:
/**
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
[].slice.call(document.querySelectorAll('.article-status')).forEach((element) => {
element.addEventListener('click', (event) => {
event.stopPropagation();
});
});
or even more compact:
/**
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
[].slice.call(document.querySelectorAll('.article-status')).forEach((element) => element.addEventListener('click', (event) => event.stopPropagation()));
@obuisard this might be a good project for 4.3: clean all the addEventListener('DOMContentLoaded', ...)
from the javascript files!
The anti pattern is explained here: https://www.youtube.com/watch?v=_iq1fPjeqMQ
I agree @dgrammatiko, this should be cleaned up. Do you mind writing a PR for this issue and if you can't work on it I will try and rally the troops so you get help :-)
@obuisard you could use #35725 as a guide.
In short the scripts need to:
type=module
+ add the -es5 in the dependenciesaddEventListener('DOMContentLoaded', ...)
as it's pure overheadStatus | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-09-02 09:13:21 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
obvioously there is an issue with drone as this should have been picked up