aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-08 23:14:32 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-09 15:52:15 +0000
commitd1885b403196af17e931c24f3c98fc8afd03f005 (patch)
treeaf3f38fb554e74bac66c4879172db1de46dcd39f /src/qml/jsruntime/qv4object.cpp
parentbcc9aa7daf197e8f2befe215902443d608e07b6a (diff)
Fix a small bug in virtualHasProperty
It should call hasProperty() on the proto if the property wasn't found locally, instead of looping and calling getOwnProperty, as this leads to subtly differences with Proxy objects. Change-Id: I088b0522c621999b7991f9194f46eaa9f6e15206 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r--src/qml/jsruntime/qv4object.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index cd9ea66297..c1f6642c9d 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -717,12 +717,13 @@ bool Object::virtualHasProperty(const Managed *m, PropertyKey id)
Scope scope(m->engine());
ScopedObject o(scope, m);
ScopedProperty p(scope);
- while (o) {
- if (o->getOwnProperty(id, p) != Attr_Invalid)
- return true;
- o = o->getPrototypeOf();
- }
+ if (o->getOwnProperty(id, p) != Attr_Invalid)
+ return true;
+
+ o = o->getPrototypeOf();
+ if (o)
+ return o->hasProperty(id);
return false;
}