-
Notifications
You must be signed in to change notification settings - Fork 15
Introduced util for checking whether the editor wasn't initialized on the same element more than once #176
Conversation
…ified sourceElement was used more than once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some updates to docs are needed - the PR is OK :) I have only one question to @Reinmar about naming the error.
|
||
if ( sourceElement.hasAttribute( SECURE_ATTRIBUTE ) ) { | ||
/** | ||
* An element passed to the editor creator has been passed more than once. The element can be used only once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* An element passed to the editor creator has been passed more than once. The element can be used only once. | |
* Another editor instance was already initialized on this element. You cannot create more then one editor on the same element. |
Or something similar - I get the feeling that the error description should reflect how someone could use our API. So it is rather creating two or more instances of the ediotr on some element then passing something.
Why not a part of |
Edit: I was wrong - @oleq this looks like a place for this util. |
I moved the method and updated other PRs. But don't merge it please, because I figured we can go further and have if ( isElement( sourceElementOrData ) ) {
this.sourceElement = sourceElementOrData;
this.secureSourceElement();
} in editor constructors as if ( isElement( sourceElementOrData ) ) {
this.setSourceElement( sourceElementOrData );
} with backwards compatibility (setting Gonna create it ASAP. |
…e it does not make sense in the mixin because the mixin is used wrongly in the first place :P
I reverted some of the changes I made because it turned out the |
Self–review: maybe instead of using |
Sounds cool :) |
Just like |
In fact... we could use |
Perfect timing. |
Ready for another round of review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I've fixed only one docs as I couldn't parse it :)
Suggested merge commit message (convention)
Feature: Introduced a
secureSourceElement()
utility that makes sure source DOM elements are not shared between editor instances. See ckeditor/ckeditor5#746.