﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
11533	Elements upcasted repeatedly if pseudo-DOM modified during upcast	Olek Nowodziński	Olek Nowodziński	"It turned out that in some cases upcasting may go out of control.

Assumptions:
1. Let's start with the following html:
 {{{
<body><p>x<img/></p></body>
}}}
2. Each <img> is to be upcasted to <figure><img></figure>.

Now let's follow `forEach`, which [https://github.com/ckeditor/ckeditor-dev/blob/9a2e1a31d334f415250514d21f047259cb161135/plugins/widget/plugin.js#L2337 calls the iterator] (see: `createUpcastIterator`) during the upcast process, step-by-step:

1. ForEach: Visit <p>.
2. ForEach: Visit children of <p>.
3. ForEach: ""x"" text found
4. Upcast: Ignore text.
5. ForEach: Visit <img>
5. Upcast: Start upcasting <img> to <figure>.
6. Upcast: Split <p> because <figure> is block.
 {{{
<body><p>x</p><p><img/></p></body>
}}}
7. Upcast: Replace the parent of <img> (<p>) with <figure>
 {{{
<body><p>x</p><figure><img/></figure></body>
}}}
8. Widget system: Remember that <figure> is to be wrapped. Great. But problems start now.
9. ForEach: No more children of <p>.
10. ForEach: Go back to <body>.
11. ForEach: Move to <figure>, which is the next child of <body>
12. ForEach: Enter <figure> (it's not a widget yet).
13. ForEach: Visit children of <figure>.
14. ForEach: Visit <img>.
15. Upcast: Start upcasting <img>.
16. Bang! Upcasting the same <img> once again, while it belongs to <figure> which is to be a widget."	Bug	closed	Normal	CKEditor 4.3.3	General	4.3	fixed		
