Skip to content

Commit

Permalink
Revert "Merge pull request #4852 from ckeditor/t/4761"
Browse files Browse the repository at this point in the history
This reverts commit 70649e5, reversing
changes made to 92173c6.
  • Loading branch information
Comandeer committed Nov 17, 2021
1 parent cab78d4 commit 48a577d
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 298 deletions.
1 change: 0 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ API Changes:
* [#4462](https://github.com/ckeditor/ckeditor4/issues/4462): [`CKEDITOR.editor#getSelection()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#method-getSelection) now returns `null` if the editor is in recreating state.
* [#4583](https://github.com/ckeditor/ckeditor4/issues/4583): Added support for new, comma-less color syntax to [`CKEDITOR.tools.color`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools_color.html).
* [#4604](https://github.com/ckeditor/ckeditor4/issues/4604): Added the [`CKEDITOR.plugins.clipboard.dataTransfer#isFileTransfer()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_clipboard_dataTransfer.html#method-isFileTransfer) method.
* [#4761](https://github.com/ckeditor/ckeditor4/issues/4761): [`CKEDITOR.dom.document#appendStyleSheet()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_document.html#method-appendStyleSheet) and [`CKEDITOR.tools.buildStyleHtml()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_tools.html#method-buildStyleHtml) now use [`CKEDITOR.getUrl()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR.html#method-getUrl) to correctly handle caching of CSS files.
* [#4790](https://github.com/ckeditor/ckeditor4/issues/4790): Added `callback` parameter to [`CKEDITOR.plugins.preview#createPreview()`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_plugins_preview.html#method-createPreview) method.

Other Changes:
Expand Down
6 changes: 3 additions & 3 deletions core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ CKEDITOR.config = {
/**
* The CSS file(s) to be used to apply style to editor content. It should
* reflect the CSS used in the target pages where the content is to be
* displayed. Every URL is passed through {@link CKEDITOR#getUrl} function.
* displayed.
*
* **Note:** This configuration value is used only in {@glink guide/dev_framed `<iframe>`-based editor }
* and ignored by {@glink guide/dev_inline inline editor}
Expand All @@ -301,9 +301,9 @@ CKEDITOR.config = {
* config.contentsCss = '/css/mysitestyles.css';
* config.contentsCss = [ '/css/mysitestyles.css', '/css/anotherfile.css' ];
*
* @cfg {String/Array} [contentsCss='contents.css']
* @cfg {String/Array} [contentsCss=CKEDITOR.getUrl( 'contents.css' )]
*/
contentsCss: 'contents.css',
contentsCss: CKEDITOR.getUrl( 'contents.css' ),

/**
* Comma-separated list of plugins to be used in an editor instance. Note that
Expand Down
4 changes: 0 additions & 4 deletions core/dom/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, {
*
* CKEDITOR.document.appendStyleSheet( '/mystyles.css' );
*
* **Note:** URLs are passed through {@link CKEDITOR#getUrl} function.
*
* @param {String} cssFileUrl The CSS file URL.
*/
appendStyleSheet: function( cssFileUrl ) {
cssFileUrl = CKEDITOR.getUrl( cssFileUrl );

if ( this.$.createStyleSheet )
this.$.createStyleSheet( cssFileUrl );
else {
Expand Down
7 changes: 2 additions & 5 deletions core/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
* Builds a HTML snippet from a set of `<style>/<link>`.
*
* @param {String/Array} css Each of which are URLs (absolute) of a CSS file or
* a trunk of style text. URLs are passed through {@link CKEDITOR#getUrl} function.
* a trunk of style text.
* @returns {String}
*/
buildStyleHtml: function( css ) {
Expand All @@ -426,11 +426,8 @@
// Is CSS style text ?
if ( /@import|[{}]/.test( item ) )
retval.push( '<style>' + item + '</style>' );
else {
item = CKEDITOR.getUrl( item );

else
retval.push( '<link type="text/css" rel=stylesheet href="' + item + '">' );
}
}
}
return retval.join( '' );
Expand Down
157 changes: 0 additions & 157 deletions tests/core/ckeditor/geturl.js

This file was deleted.

13 changes: 0 additions & 13 deletions tests/core/ckeditor/manual/geturl.html

This file was deleted.

10 changes: 0 additions & 10 deletions tests/core/ckeditor/manual/geturl.md

This file was deleted.

33 changes: 2 additions & 31 deletions tests/core/dom/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ bender.test( appendDomObjectTests(
assert.areSame( document, doc.$ );
},

// (#4761)
test_appendStyleSheet_notimestamp: function() {
var originalTimestamp = CKEDITOR.timestamp,
cssUrl = CKEDITOR.basePath + 'tests/_assets/sample.css';

CKEDITOR.timestamp = '';
test_appendStyleSheet: function() {
var cssUrl = CKEDITOR.basePath + 'tests/_assets/sample.css';

var doc = new CKEDITOR.dom.document( document );
doc.appendStyleSheet( cssUrl );
Expand All @@ -34,31 +30,6 @@ bender.test( appendDomObjectTests(
}
}

CKEDITOR.timestamp = originalTimestamp;
assert.isTrue( succeed, 'The link element was not found' );
},

// (#4761)
test_appendStyleSheet_timestamp: function() {
var originalTimestamp = CKEDITOR.timestamp,
cssUrl = CKEDITOR.basePath + 'tests/_assets/sample.css',
expectedUrl = cssUrl + '?t=wer56';

CKEDITOR.timestamp = 'wer56';

var doc = new CKEDITOR.dom.document( document );
doc.appendStyleSheet( cssUrl );

var links = document.getElementsByTagName( 'link' );
var succeed = false;
for ( var i = 0 ; i < links.length ; i++ ) {
if ( links[ i ].href == expectedUrl ) {
succeed = true;
break;
}
}

CKEDITOR.timestamp = originalTimestamp;
assert.isTrue( succeed, 'The link element was not found' );
},

Expand Down
74 changes: 0 additions & 74 deletions tests/core/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,80 +1177,6 @@
assert.areSame( 2, testSpy.callCount );
assert.areSame( testObj, testSpy.getCall( 0 ).thisValue );
assert.isTrue( testSpy.calledWithExactly( 'baz', 100, 'bar' ) );
},

// (#4761)
'test buildStyleHtml with no timestamp returns stylesheet URL without cache key for passed string': function() {
var originalTimestamp = CKEDITOR.timestamp,
url = '/file.css',
expectedHref = 'href="' + url + '"',
html;

CKEDITOR.timestamp = '';
html = CKEDITOR.tools.buildStyleHtml( url ),
CKEDITOR.timestamp = originalTimestamp;

assert.areNotSame( -1, html.indexOf( expectedHref ), 'Built HTML includes correct stylesheet link' );
},

// (#4761)
'test buildStyleHtml with set timestamp returns stylesheet URL with cache key for passed string': function() {
var originalTimestamp = CKEDITOR.timestamp,
newTimestamp = 'wer55',
url = '/file.css',
expectedHref = 'href="' + url + '?t=' + newTimestamp + '"',
html;

CKEDITOR.timestamp = newTimestamp;
html = CKEDITOR.tools.buildStyleHtml( url ),
CKEDITOR.timestamp = originalTimestamp;

assert.areNotSame( -1, html.indexOf( expectedHref ), 'Built HTML includes correct stylesheet link' );
},

// (#4761)
'test buildStyleHtml with no timestamp returns stylesheet URLs without cache key for passed array': function() {
var originalTimestamp = CKEDITOR.timestamp,
urls = [
'/file.css',
'/some-other-file'
],
expectedHrefs = [
'href="' + urls[ 0 ] + '"',
'href="' + urls[ 1 ] + '"'
],
html;

CKEDITOR.timestamp = '';
html = CKEDITOR.tools.buildStyleHtml( urls ),
CKEDITOR.timestamp = originalTimestamp;

CKEDITOR.tools.array.forEach( expectedHrefs, function( expectedHref ) {
assert.areNotSame( -1, html.indexOf( expectedHref ), 'Built HTML includes correct stylesheet link' );
} );
},

// (#4761)
'test buildStyleHtml with set timestamp returns stylesheet URLs with cache key for passed array': function() {
var originalTimestamp = CKEDITOR.timestamp,
newTimestamp = 'wer55',
urls = [
'/file.css',
'/some-other-file'
],
expectedHrefs = [
'href="' + urls[ 0 ] + '?t=' + newTimestamp + '"',
'href="' + urls[ 1 ] + '?t=' + newTimestamp + '"'
],
html;

CKEDITOR.timestamp = newTimestamp;
html = CKEDITOR.tools.buildStyleHtml( urls ),
CKEDITOR.timestamp = originalTimestamp;

CKEDITOR.tools.array.forEach( expectedHrefs, function( expectedHref ) {
assert.areNotSame( -1, html.indexOf( expectedHref ), 'Built HTML includes correct stylesheet link' );
} );
}
} );
} )();

0 comments on commit 48a577d

Please sign in to comment.