﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
14650	classes on fake elements via createFakeParserElement not coming back properly.	Tyler		"Sorry, this is difficult to do ""steps to complete"".  I encountered a bug doing custom plugin development - it relates to using a class as part of a fake object.

I created a custom plugin that overrides/enhances functionality of the anchor component of the link plugin.  The only change I made was to add a custom className to created anchors, so they can work with a fixed header.

I took the existing anchor dialog pretty much verbatim - the only change was 'attributes' property the fake is created with now includes a `class: 'anchor'` declaration.  I'm pretty sure this can be recreated by editing the attribtues in the anchor dialog to include `class: ""test""`, saving and refreshing.

https://github.com/ckeditor/ckeditor-dev/blob/67ae77b/plugins/link/dialogs/anchor.js#L27-L31

This works fine when inserting a fresh anchor however after reloading the page, the filter that runs as part of the ""link"" plugin tries to convert the html for anchors back to fakeobjects.

At this point, `createFakeParserElement` is called with the element, here: https://github.com/ckeditor/ckeditor-dev/blob/bd5101a/plugins/link/plugin.js#L184 ... at this point, element includes `attributes` which includes ""name/id/data-cke-saved-name"" and `classes` which includes ""anchor"".  

The return value from this function is a fake object -- decoding the `data-cke-realelement` reveals that the real element does not have a class -- so performing a save at this point has the effect of stripping out the class name.

I was able to work around this with my own data filter rule that runs before the one in the link plugin - this will check for the presence of `classes` and if found, will add a ""class"" attribute to element.attributes - this seems to work fine, `createFakeParserElement` works fine if there is a class property in the attribute hash.

{{{

    editor.dataProcessor.dataFilter.addRules({
      elements: {
        a: function (element) {
          if (!element.attributes.name) { return null; }
          if (!element.children.length && element.classes.length) {
            element.attributes.class = element.classes.join(' ');
          }
          return null; // if we don't return, it passes along to the next filter.
        }
      }
    }, 9);

}}}

I think the bug here is that `createFakeParserElement` does not respect 'classes' inside the element it is passed.

I encountered this issue on 4.5.8 and am unsure if it is recreatable in other versions."	Bug	closed	Normal		General		invalid		
