Fix Array.prototype.splice to not require the instance to be a true array
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 12:22:49 +0000 (14:22 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 15:46:45 +0000 (17:46 +0200)
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<QString>

Change-Id: Ic9cbf12d625adf7c3c47ce4a7996d2623f843601
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4arrayobject.cpp

index 2d4068d..b1226a3 100644 (file)
@@ -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));