diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-07-03 17:21:31 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-30 20:44:50 +0000 |
commit | 1cde99fbafe035cbd88237d8e0a3b52b780f68af (patch) | |
tree | ccc1057c42f6e2768323f1caa069f2236c6163f3 /src/qml/jsruntime/qv4object.cpp | |
parent | 55d0327ddf2b7b59d686218a9eb7f340732136ef (diff) |
Make Array.prototype.concat comply better with the spec
There are still some failures in the test cases, but at least
less than before.
Change-Id: I5bad4ddb1e9d6fe120e981f806a6d986fd43b64d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index e4d670d4f3..718bfbe5ec 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -51,6 +51,7 @@ #include "qv4identifiertable_p.h" #include "qv4jscall_p.h" #include "qv4symbol_p.h" +#include "qv4proxy_p.h" #include <stdint.h> @@ -930,6 +931,32 @@ void Object::initSparseArray() ArrayData::realloc(this, Heap::ArrayData::Sparse, 0, false); } +bool Object::isConcatSpreadable() const +{ + Scope scope(this); + ScopedValue spreadable(scope, get(scope.engine->symbol_isConcatSpreadable())); + if (!spreadable->isUndefined()) + return spreadable->toBoolean(); + return isArray(); +} + +bool Object::isArray() const +{ + if (isArrayObject()) + return true; + if (vtable() == ProxyObject::staticVTable()) { + const ProxyObject *p = static_cast<const ProxyObject *>(this); + Scope scope(this); + if (!p->d()->handler) { + scope.engine->throwTypeError(); + return false; + } + ScopedObject o(scope, p->d()->target); + return o->isArray(); + } + return false; +} + DEFINE_OBJECT_VTABLE(ArrayObject); |