diff --git a/core/dom/document.js b/core/dom/document.js index 438b1fc8738..a4cf5fb04e4 100644 --- a/core/dom/document.js +++ b/core/dom/document.js @@ -43,6 +43,9 @@ CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, { * @param {String} cssFileUrl The CSS file URL. */ appendStyleSheet: function( cssFileUrl ) { + var cacheKey = CKEDITOR.timestamp ? '?t=' + CKEDITOR.timestamp : ''; + cssFileUrl += cacheKey; + if ( this.$.createStyleSheet ) this.$.createStyleSheet( cssFileUrl ); else { diff --git a/tests/core/dom/document.js b/tests/core/dom/document.js index 5637766e7d7..bfac3ef6239 100644 --- a/tests/core/dom/document.js +++ b/tests/core/dom/document.js @@ -24,10 +24,30 @@ bender.test( appendDomObjectTests( var doc = new CKEDITOR.dom.document( document ); doc.appendStyleSheet( cssUrl );// this makes absolute URL no matter what is passed - var links = document.getElementsByTagName( 'link' ); - var succeed = CKEDITOR.tools.array.some( links, function( link ) { - return link.href === cssUrl; - } ); + var links = document.getElementsByTagName( 'link' ), + succeed = CKEDITOR.tools.array.some( links, function( link ) { + return link.href === cssUrl; + } ); + + CKEDITOR.timestamp = originalTimestamp; + assert.isTrue( succeed, 'The link element was not found' ); + }, + + // (#4761) + 'test appendStyleSheet with timestamp': function() { + var originalTimestamp = CKEDITOR.timestamp, + fakeTimestamp = 'cke4', + cssUrl = CKEDITOR.basePath + 'tests/_assets/sample.css', + expectedCssUrl = cssUrl + '?t=' + fakeTimestamp; + + CKEDITOR.timestamp = fakeTimestamp; + var doc = new CKEDITOR.dom.document( document ); + doc.appendStyleSheet( cssUrl );// this makes absolute URL no matter what is passed + + var links = document.getElementsByTagName( 'link' ), + succeed = CKEDITOR.tools.array.some( links, function( link ) { + return link.href === expectedCssUrl; + } ); CKEDITOR.timestamp = originalTimestamp; assert.isTrue( succeed, 'The link element was not found' );