Skip to content

Conversation

@michaeldimoudis
Copy link

… [object Array Iterator]

When using ES6 features (ReactJS/lodash/etc) on your page, the CKEditor core tools isArray function does not know how to check the ES Iteration Protocol, as described here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

This is a simple fix by also comparing to [object Array Iterator] in the isArray function in tools.js

@michaeldimoudis michaeldimoudis changed the title Fix isArray function in core tools to recognize ES6 iterator protocol… #16906 Fix isArray function in core tools to recognize ES6 iterator protocol… Mar 17, 2017
@mlewand mlewand self-assigned this Mar 17, 2017
@mlewand mlewand self-requested a review March 17, 2017 00:35
Copy link
Contributor

@mlewand mlewand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array iterator is not an Array-like object. As such should not be recognized by isArray.

The proper way here would be to add isIterator method, but do we really need it? What is the use case?

@mlewand mlewand removed their assignment Mar 17, 2017
@michaeldimoudis
Copy link
Author

Hi @mlewand thanks for the quick reply. CKEditor was working well for us, until we added some ReactJS code on our page, and the initialization broke. We believe ReactJS and/or lodash, using ES6, is interfering with the initialization of CKEditor, due to an array in CKEditor getting converted to an iterator for some reason. I have added a ticket here with more information: https://dev.ckeditor.com/ticket/16906

The dynamically generated plugins <script> tag becomes malformed. Ie:
<script type="text/javascript" src="​https://mydomain/_js/Performance2/ckeditor-full.4.6.2/plugins/dialogui,dialog,about,a11yhelp,dialogadvtab,basicstyles,bidi,blockquote,clipboard,button,panelbutton,panel,floatpanel,colorbutton,colordialog,templates,menu,copyformatting,div,toolbar,enterkey,entities,popup,filebrowser,find,fakeobjects,flash,floatingspace,listblock,richcombo,font,forms,format,horizontalrule,htmlwriter,iframe,wysiwygarea,image,indent,indentblock,indentlist,smiley,justify,menubutton,language,link,list,magicline,maximize,newpage,pagebreak,pastetext,pastefromword,preview,print,removeformat,save,selectall,showblocks,showborders,sourcearea,specialchar,stylescombo,tab,table,undo,wsc/plugin.js?t=v0.01"></script>

Do you think we should add an isIterator function, and check against that too when building the above script tag?

@mlewand
Copy link
Contributor

mlewand commented Mar 17, 2017

Hi @michaeldimoudis,

The dynamically generated plugins <script> tag becomes malformed.

Interesting. Could I ask you to expose minimal setup to reproduce it? Codepen, jsfiddle or a GitHub repo would do.

Do you think we should add an isIterator function, and check against that too when building the above script tag?

Yes, that would be the correct way to handle it.

@mlewand
Copy link
Contributor

mlewand commented Apr 6, 2017

Hi, It's been a while since we last heard from you. We're closing this issue for now. Still, feel free provide us requested feedback, so that we can reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants