Use ES module

This commit is contained in:
Andrej 2019-05-27 07:02:04 +07:00
parent 8f8b06232a
commit 271cba918a
2 changed files with 8 additions and 6 deletions

View File

@ -22,6 +22,7 @@ class CustomController extends Controller{
super(object, property);
object.constructor( this );
this.custom = true;
}
}

View File

@ -521,7 +521,7 @@ common.extend(
object,
property,
{
custom: object instanceof CustomController,
custom: object.custom,
factoryArgs: Array.prototype.slice.call(arguments, 2)
}
);
@ -1154,7 +1154,8 @@ function recallSavedValue(gui, controller) {
}
function add(gui, object, property, params) {
if (!object instanceof CustomController && !params.custom && (object[property] === undefined)) {
var customObject = object.custom;
if (!customObject && !params.custom && (object[property] === undefined)) {
throw new Error(`Object "${object}" has no property "${property}"`);
}
@ -1162,12 +1163,12 @@ function add(gui, object, property, params) {
if (params.color) {
controller = new ColorController(object, property);
} else if(object instanceof CustomController && ( property === undefined )){
} else if(customObject && ( property === undefined )){
controller = object;
} else if (!(object instanceof CustomController) && params.custom && (object[property] === undefined)) {
} else if (!(customObject) && params.custom && (object[property] === undefined)) {
controller = new CustomController(object, property);
}else {
const factoryArgs = object instanceof CustomController ?
const factoryArgs = customObject ?
[property].concat(params.factoryArgs) : [object, property].concat(params.factoryArgs);
controller = ControllerFactory.apply(gui, factoryArgs);
}
@ -1183,7 +1184,7 @@ function add(gui, object, property, params) {
const container = document.createElement('div');
const name = params.custom && ( controller instanceof CustomController === false ) ?
( object instanceof CustomController ? object.domElement : new CustomController(object).domElement ) : document.createElement('span');
( customObject ? object.domElement : new CustomController(object).domElement ) : document.createElement('span');
if (!params.custom)
name.innerHTML = controller.property;
dom.addClass(name, 'property-name');