|
|
@@ -27,10 +27,6 @@ export default class EditableUIView extends View {
|
|
|
|
|
|
const bind = this.bindTemplate;
|
|
|
|
|
|
- if ( editableElement ) {
|
|
|
- this.element = this.editableElement = editableElement;
|
|
|
- }
|
|
|
-
|
|
|
this.setTemplate( {
|
|
|
tag: 'div',
|
|
|
attributes: {
|
|
|
@@ -64,20 +60,21 @@ export default class EditableUIView extends View {
|
|
|
this.set( 'isFocused', false );
|
|
|
|
|
|
/**
|
|
|
- * An external {@link #editableElement} passed into the constructor, which also means
|
|
|
- * the view will not render its {@link #template}.
|
|
|
+ * The element which is the main editable element (usually the one with `contentEditable="true"`).
|
|
|
*
|
|
|
- * @protected
|
|
|
- * @member {HTMLElement} #_externalElement
|
|
|
+ * @readonly
|
|
|
+ * @member {HTMLElement} #editableElement
|
|
|
*/
|
|
|
- this._externalElement = editableElement;
|
|
|
+ this.editableElement = editableElement;
|
|
|
|
|
|
/**
|
|
|
- * The element which is the main editable element (usually the one with `contentEditable="true"`).
|
|
|
+ * Whether an external {@link #editableElement} was passed into the constructor, which also means
|
|
|
+ * the view will not render its {@link #template}.
|
|
|
*
|
|
|
- * @readonly
|
|
|
- * @member {HTMLElement} #editableElement
|
|
|
+ * @protected
|
|
|
+ * @member {HTMLElement} #_hasExternalElement
|
|
|
*/
|
|
|
+ this._hasExternalElement = !!this.editableElement;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -87,8 +84,8 @@ export default class EditableUIView extends View {
|
|
|
render() {
|
|
|
super.render();
|
|
|
|
|
|
- if ( this._externalElement ) {
|
|
|
- this.template.apply( this.element = this._externalElement );
|
|
|
+ if ( this._hasExternalElement ) {
|
|
|
+ this.template.apply( this.element = this.editableElement );
|
|
|
} else {
|
|
|
this.editableElement = this.element;
|
|
|
}
|
|
|
@@ -98,8 +95,8 @@ export default class EditableUIView extends View {
|
|
|
* @inheritDoc
|
|
|
*/
|
|
|
destroy() {
|
|
|
- if ( this._externalElement ) {
|
|
|
- this.template.revert( this._externalElement );
|
|
|
+ if ( this._hasExternalElement ) {
|
|
|
+ this.template.revert( this.editableElement );
|
|
|
}
|
|
|
|
|
|
super.destroy();
|