-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom type attribute in scriptLoader method with new parameter T/5434 #5435
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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'; | ||||||||||||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In newer code we use braces. There are absent in this file due to its age (in older code we were often omitting them):
Suggested change
|
||||||||||||
|
||||||||||||
var scriptCount = scriptUrl.length, | ||||||||||||
scriptCountDoCallback = scriptCount, | ||||||||||||
completed = [], | ||||||||||||
|
@@ -115,7 +122,7 @@ CKEDITOR.scriptLoader = ( function() { | |||||||||||
// Create the <script> element. | ||||||||||||
var script = new CKEDITOR.dom.element( 'script' ); | ||||||||||||
script.setAttributes( { | ||||||||||||
type: 'text/javascript', | ||||||||||||
type: typeAttribute, | ||||||||||||
src: url | ||||||||||||
} ); | ||||||||||||
|
||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,23 @@ var tests = { | |
this.wait(); | ||
}, | ||
|
||
'test load with custom type attribute': function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test fails in all browsers. The first reason is the usage of the However, even after this change, the test still fails – probably due to the fact that the Additionally, this test won't work in Internet Explorer as it won't preserve the if ( CKEDITOR.env.ie ) {
assert.ignore();
} |
||
var tc = this; | ||
|
||
function callback() { | ||
tc.resume( function() { | ||
var script = CKEDITOR.document.findOne( 'script[src="../_assets/sample.js"]' ); | ||
|
||
assert.areSame( script.$.attr( 'type' ), 'module' ); | ||
assert.areSame( 'Test!', testVar ); | ||
} ); | ||
} | ||
|
||
CKEDITOR.scriptLoader.load( '../_assets/sample.js', callback, CKEDITOR, false, 'module' ); | ||
|
||
this.wait(); | ||
}, | ||
|
||
'test load event handling': function() { | ||
var tc = this; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To indicate the default value of the parameter, please use the
[key=value]
syntax – it's automatically recognized by our documentation generator and transformed into appropriate information about the default value: