From 91a835a1731a10e73546057196855b3fa685f95a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 13 Jun 2013 14:22:49 +0200 Subject: [PATCH] Fix Array.prototype.splice to not require the instance to be a true array Use putIndexed instead of arraySet, so that it also works with "host" arrays. Fixes tst_qqmlecmascript::sequenceConversionArray, which calls splice on a JS-wrapped QList Change-Id: Ic9cbf12d625adf7c3c47ce4a7996d2623f843601 Reviewed-by: Lars Knoll --- src/qml/qml/v4/qv4arrayobject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/v4/qv4arrayobject.cpp b/src/qml/qml/v4/qv4arrayobject.cpp index 2d4068d..b1226a3 100644 --- a/src/qml/qml/v4/qv4arrayobject.cpp +++ b/src/qml/qml/v4/qv4arrayobject.cpp @@ -462,7 +462,7 @@ Value ArrayPrototype::method_splice(SimpleCallContext *ctx) bool exists; Value v = instance->getIndexed(ctx, k + deleteCount, &exists); if (exists) - instance->arraySet(k + itemCount, v); + instance->putIndexed(k + itemCount, v); else instance->deleteIndexedProperty(ctx, k + itemCount); } @@ -474,7 +474,7 @@ Value ArrayPrototype::method_splice(SimpleCallContext *ctx) bool exists; Value v = instance->getIndexed(ctx, k + deleteCount - 1, &exists); if (exists) - instance->arraySet(k + itemCount - 1, v); + instance->putIndexed(k + itemCount - 1, v); else instance->deleteIndexedProperty(ctx, k + itemCount - 1); --k; @@ -482,7 +482,7 @@ Value ArrayPrototype::method_splice(SimpleCallContext *ctx) } for (uint i = 0; i < itemCount; ++i) - instance->arraySet(start + i, ctx->argument(i + 2)); + instance->putIndexed(start + i, ctx->argument(i + 2)); ctx->strictMode = true; instance->put(ctx, ctx->engine->id_length, Value::fromDouble(len - deleteCount + itemCount)); -- 2.7.4