|
|
@@ -8,7 +8,6 @@
|
|
|
*/
|
|
|
|
|
|
import View from '../view';
|
|
|
-import Template from '../template';
|
|
|
|
|
|
/**
|
|
|
* The iframe view class.
|
|
|
@@ -26,7 +25,7 @@ export default class IframeView extends View {
|
|
|
|
|
|
const bind = this.bindTemplate;
|
|
|
|
|
|
- this.template = new Template( {
|
|
|
+ this.setTemplate( {
|
|
|
tag: 'iframe',
|
|
|
attributes: {
|
|
|
class: [ 'ck-reset_all' ],
|
|
|
@@ -38,45 +37,27 @@ export default class IframeView extends View {
|
|
|
load: bind.to( 'loaded' )
|
|
|
}
|
|
|
} );
|
|
|
-
|
|
|
- /**
|
|
|
- * A promise returned by {@link #init} since iframe loading may be asynchronous.
|
|
|
- *
|
|
|
- * **Note**: Listening to `load` in {@link #init} makes no sense because at this point
|
|
|
- * the element is already in the DOM and the `load` event might already be fired.
|
|
|
- *
|
|
|
- * See {@link #_iframeDeferred}.
|
|
|
- *
|
|
|
- * @private
|
|
|
- * @member {Promise}
|
|
|
- */
|
|
|
- this._iframePromise = new Promise( ( resolve, reject ) => {
|
|
|
- /**
|
|
|
- * A deferred object used to resolve the iframe promise associated with
|
|
|
- * asynchronous loading of `contentDocument`. See {@link #_iframePromise}.
|
|
|
- *
|
|
|
- * @private
|
|
|
- * @member {Object}
|
|
|
- */
|
|
|
- this._iframeDeferred = { resolve, reject };
|
|
|
- } );
|
|
|
-
|
|
|
- this.on( 'loaded', () => {
|
|
|
- this._iframeDeferred.resolve();
|
|
|
- } );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Initializes iframe {@link #element} and returns a `Promise` for asynchronous
|
|
|
+ * Renders the iframe's {@link #element} and returns a `Promise` for asynchronous
|
|
|
* child `contentDocument` loading process. See {@link #_iframePromise}.
|
|
|
*
|
|
|
* @returns {Promise} A promise which resolves once the iframe `contentDocument` has
|
|
|
* been {@link #event:loaded}.
|
|
|
*/
|
|
|
- init() {
|
|
|
- super.init();
|
|
|
+ render() {
|
|
|
+ let deferred = {};
|
|
|
|
|
|
- return this._iframePromise;
|
|
|
+ this.on( 'loaded', () => {
|
|
|
+ deferred.resolve();
|
|
|
+ } );
|
|
|
+
|
|
|
+ super.render();
|
|
|
+
|
|
|
+ return new Promise( ( resolve, reject ) => {
|
|
|
+ deferred = { resolve, reject };
|
|
|
+ } );
|
|
|
}
|
|
|
}
|
|
|
|