From 7e3dfdfa132db05e9aa980d7141d660f14b35503 Mon Sep 17 00:00:00 2001 From: Matt Hand <34258655+matthandus@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:04:37 -0500 Subject: [PATCH 1/3] Add typeAttribute parameter to scriptloader.js load method. Support custom type attributes on the rendered script tag using a new typeAttribute parameter that defaults to 'text/javascript'. --- core/scriptloader.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/scriptloader.js b/core/scriptloader.js index 855c32aad72..2da0bde8d0a 100644 --- a/core/scriptloader.js +++ b/core/scriptloader.js @@ -36,6 +36,8 @@ CKEDITOR.scriptLoader = ( function() { * alert( 'Number of failures: ' + failed.length ); * } ); * + * CKEDITOR.scriptLoader.load( '/myscript.js', callback, CKEDITOR, false, 'module' ); + * * @param {String/Array} scriptUrl One or more URLs pointing to the * scripts to be loaded. * @param {Function} [callback] A function to be called when the script @@ -48,8 +50,10 @@ CKEDITOR.scriptLoader = ( function() { * the callback call. Defaults to {@link CKEDITOR}. * @param {Boolean} [showBusy] Changes the cursor of the document while * the script is loaded. + * @param {String} [typeAttribute] Set a custom type attribute on the + * script tag. Defaults to `text/javascript`. */ - load: function( scriptUrl, callback, scope, showBusy ) { + load: function( scriptUrl, callback, scope, showBusy, typeAttribute ) { var isString = ( typeof scriptUrl == 'string' ); if ( isString ) @@ -58,6 +62,9 @@ CKEDITOR.scriptLoader = ( function() { if ( !scope ) scope = CKEDITOR; + if ( !typeAttribute ) + typeAttribute = 'text/javascript'; + var scriptCount = scriptUrl.length, scriptCountDoCallback = scriptCount, completed = [], @@ -115,7 +122,7 @@ CKEDITOR.scriptLoader = ( function() { // Create the