Skip to content

Commit fafab77

Browse files
committed
Merge branch 't/13385'
2 parents 9966124 + 846ae53 commit fafab77

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Fixed Issues:
1212
* [#13419](http://dev.ckeditor.com/ticket/13419): Fixed: [Auto Link](http://ckeditor.com/addon/autolink) plugin does not encode double quotes in URLs.
1313
* [#13460](http://dev.ckeditor.com/ticket/13460): [IE8] Fixed: Copying inline widgets is broken when the Advanced Content Filter is disabled.
1414
* [#13495](http://dev.ckeditor.com/ticket/13495): [Firefox,IE] Fixed: Text is not word-wrapped in the Paste dialog.
15+
* [#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.
1516

1617
## CKEditor 4.5.1
1718

core/editor.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,26 @@
904904
*
905905
* alert( editor.getSnapshot() );
906906
*
907-
* @see CKEDITOR.editor#getData
907+
* See also:
908+
*
909+
* * {@link CKEDITOR.editor#getData}.
910+
*
911+
* @returns {String} Editor "raw data".
908912
*/
909913
getSnapshot: function() {
910914
var data = this.fire( 'getSnapshot' );
911915

912916
if ( typeof data != 'string' ) {
913917
var element = this.element;
914-
if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
918+
919+
if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) {
915920
data = element.is( 'textarea' ) ? element.getValue() : element.getHtml();
921+
}
922+
else {
923+
// If we don't have a proper element, set data to an empty string,
924+
// as this method is expected to return a string. (#13385)
925+
data = '';
926+
}
916927
}
917928

918929
return data;

tests/core/editor/destroy.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,16 @@ bender.test(
2525
} );
2626

2727
} );
28+
},
29+
30+
// #13385.
31+
'test getSnapshot returns empty string after editor destroyed': function() {
32+
bender.editorBot.create( {}, function( bot ) {
33+
this.wait( function() {
34+
var editor = bot.editor;
35+
editor.destroy();
36+
assert.areSame( '', editor.getSnapshot() );
37+
}, 0 );
38+
} );
2839
}
29-
} );
40+
} );

0 commit comments

Comments
 (0)