Skip to content

Commit

Permalink
Merge branch 't/13385'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Jul 8, 2015
2 parents 9966124 + 846ae53 commit fafab77
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -12,6 +12,7 @@ Fixed Issues:
* [#13419](http://dev.ckeditor.com/ticket/13419): Fixed: [Auto Link](http://ckeditor.com/addon/autolink) plugin does not encode double quotes in URLs.
* [#13460](http://dev.ckeditor.com/ticket/13460): [IE8] Fixed: Copying inline widgets is broken when the Advanced Content Filter is disabled.
* [#13495](http://dev.ckeditor.com/ticket/13495): [Firefox,IE] Fixed: Text is not word-wrapped in the Paste dialog.
* [#13385](http://dev.ckeditor.com/ticket/13385): Fixed: [`editor.getSnapshot()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-getSnapshot) may return a non-string value.

## CKEditor 4.5.1

Expand Down
15 changes: 13 additions & 2 deletions core/editor.js
Expand Up @@ -904,15 +904,26 @@
*
* alert( editor.getSnapshot() );
*
* @see CKEDITOR.editor#getData
* See also:
*
* * {@link CKEDITOR.editor#getData}.
*
* @returns {String} Editor "raw data".
*/
getSnapshot: function() {
var data = this.fire( 'getSnapshot' );

if ( typeof data != 'string' ) {
var element = this.element;
if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )

if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) {
data = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
}
else {
// If we don't have a proper element, set data to an empty string,
// as this method is expected to return a string. (#13385)
data = '';
}
}

return data;
Expand Down
13 changes: 12 additions & 1 deletion tests/core/editor/destroy.js
Expand Up @@ -25,5 +25,16 @@ bender.test(
} );

} );
},

// #13385.
'test getSnapshot returns empty string after editor destroyed': function() {
bender.editorBot.create( {}, function( bot ) {
this.wait( function() {
var editor = bot.editor;
editor.destroy();
assert.areSame( '', editor.getSnapshot() );
}, 0 );
} );
}
} );
} );

0 comments on commit fafab77

Please sign in to comment.