Commit d82f3c5f authored by Robert Knight's avatar Robert Knight

Revert change to move `super` to top of constructor

It turns out that there is an implicit requirement that `Host` call its
parent constructor _after_ the `.annotator-frame` element has been
created and added to the DOM. This needs refactoring to avoid the hidden
dependency, but I'm leaving that for later to focus on the CoffeeScript
=> JS conversion here.
parent 8280c93b
......@@ -6,8 +6,6 @@ const Guest = require('./guest');
export default class Host extends Guest {
constructor(element, config) {
super(element, config);
// Some config settings are not JSON-stringifiable (e.g. JavaScript
// functions) and will be omitted when the config is JSON-stringified.
// Add a JSON-stringifiable option for each of these so that the sidebar can
......@@ -65,20 +63,32 @@ export default class Host extends Guest {
);
}
let externalFrame;
let frame;
if (externalContainer) {
this.externalFrame = $(externalContainer);
externalFrame = $(externalContainer);
} else {
this.frame = $('<div></div>')
frame = $('<div></div>')
.css('display', 'none')
.addClass('annotator-frame annotator-outer');
if (config.theme === 'clean') {
this.frame.addClass('annotator-frame--drop-shadow-enabled');
frame.addClass('annotator-frame--drop-shadow-enabled');
}
this.frame.appendTo(element);
frame.appendTo(element);
}
// FIXME: We have to call the parent constructor here instead of at the top
// of the function because it triggers plugin construction and the BucketBar
// plugin constructor in turn assumes that the `.annotator-frame` element is
// already in the DOM.
super(element, config);
this.externalFrame = externalFrame;
this.frame = frame;
app.appendTo(this.frame || this.externalFrame);
this.on('panelReady', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment