﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
13410	[Embedbase, autoembed] Error thrown when undo action follows widget.loadContent	Olek Nowodziński	Szymon Kupś	"1. Go to http://tests.ckeditor.dev:1030/tests/plugins/autoembed/manual/autoembed.
2. Copy an embed link.
3. Paste it.
4. CTRL+Z immediately, before it embeds.

**Expected**: Embedding is aborted.

**Actual**: `TypeError: Cannot set property 'ready' of null` error is thrown

**The reason**: `autoEmbedLink()` function calls `loadContent()` on a temporary widget instance (located in docFragment), which is registered in `widgetRepo.instances`. When undo is executed, editor's DOM is reloaded and the widget repository demolished, then re–built for the new DOM. Thus when `loadContent()` callback is executed, there's a brand new widget repository, which does not contain that initial temporary widget instance since it was located in docFragment. Finally `editor.widgets.finalizeCreation( temp )` is called. However, because `temp` belongs to a widget instance, which is no longer registered in the repository, the widget is not found and the error is thrown.

**Cake recipe**: The fix should land in `embedbase`. `loadContent` should check if the widget still belongs to editor's widget repository first.

**To–do**: Check if the fix covers the case when ""Source"" is pressed instead of ""Undo""."	Bug	closed	Normal	CKEditor 4.5.2	UI : Widgets	4.5.0	fixed		
