@@ -83,6 +83,23 @@ describe( 'InlineEditor', () => {
8383 expect ( editor . editing . view . getDomRoot ( ) ) . to . equal ( editor . ui . element ) ;
8484 } ) ;
8585 } ) ;
86+
87+ // See: https://github.com/ckeditor/ckeditor5/issues/746
88+ it ( 'should throw when trying to create the editor using the same source element more than once' , done => {
89+ InlineEditor . create ( editorElement )
90+ . then (
91+ ( ) => {
92+ expect . fail ( 'Inline editor should not initialize on an element already used by other instance.' ) ;
93+ } ,
94+ err => {
95+ assertCKEditorError ( err ,
96+ / ^ e d i t o r - s o u r c e - e l e m e n t - a l r e a d y - u s e d /
97+ ) ;
98+ }
99+ )
100+ . then ( done )
101+ . catch ( done ) ;
102+ } ) ;
86103 } ) ;
87104
88105 describe ( 'create()' , ( ) => {
@@ -117,6 +134,9 @@ describe( 'InlineEditor', () => {
117134 } ) ;
118135
119136 it ( 'should not require config object' , ( ) => {
137+ const editorElement = document . createElement ( 'div' ) ;
138+ editorElement . innerHTML = '<p><strong>foo</strong> bar</p>' ;
139+
120140 // Just being safe with `builtinPlugins` static property.
121141 class CustomInlineEditor extends InlineEditor { }
122142 CustomInlineEditor . builtinPlugins = [ Paragraph , Bold ] ;
@@ -126,6 +146,9 @@ describe( 'InlineEditor', () => {
126146 expect ( newEditor . getData ( ) ) . to . equal ( '<p><strong>foo</strong> bar</p>' ) ;
127147
128148 return newEditor . destroy ( ) ;
149+ } )
150+ . then ( ( ) => {
151+ editorElement . remove ( ) ;
129152 } ) ;
130153 } ) ;
131154
@@ -140,13 +163,18 @@ describe( 'InlineEditor', () => {
140163 } ) ;
141164
142165 it ( 'initializes with config.initialData' , ( ) => {
166+ const editorElement = document . createElement ( 'div' ) ;
167+ editorElement . innerHTML = '<p>Hello world!</p>' ;
168+
143169 return InlineEditor . create ( editorElement , {
144170 initialData : '<p>Hello world!</p>' ,
145171 plugins : [ Paragraph ]
146172 } ) . then ( editor => {
147173 expect ( editor . getData ( ) ) . to . equal ( '<p>Hello world!</p>' ) ;
148174
149- editor . destroy ( ) ;
175+ return editor . destroy ( ) ;
176+ } ) . then ( ( ) => {
177+ editorElement . remove ( ) ;
150178 } ) ;
151179 } ) ;
152180
0 commit comments