new Object(x) should convert x to an object and return
it if x is not null or undefined
Change-Id: Icb5547a23df83018757901bfecb5f024610e7c68
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Value ObjectCtor::construct(ExecutionContext *ctx)
{
- ctx->thisObject = Value::fromObject(ctx->engine->newObject());
+ if (!ctx->argumentCount || ctx->argument(0).isUndefined() || ctx->argument(0).isNull())
+ ctx->thisObject = Value::fromObject(ctx->engine->newObject());
+ else
+ ctx->thisObject = __qmljs_to_object(ctx->argument(0), ctx);
return ctx->thisObject;
}