static njs_value_t *
-njs_function_property_prototype_create(njs_vm_t *vm, njs_lvlhsh_t *hash,
+njs_function_property_prototype_set(njs_vm_t *vm, njs_lvlhsh_t *hash,
njs_value_t *prototype)
{
njs_int_t ret;
return NJS_ERROR;
}
- proto = njs_function_property_prototype_create(vm, &function->object.hash,
- setval);
+ proto = njs_function_property_prototype_set(vm, njs_object_hash(value),
+ setval);
if (njs_slow_path(proto == NULL)) {
return NJS_ERROR;
}
- if (njs_is_object(proto)) {
+ if (setval == &proto_value && njs_is_object(proto)) {
+ /* Only in getter context. */
cons = njs_property_constructor_create(vm, njs_object_hash(proto),
value);
if (njs_slow_path(cons == NULL)) {
"x.t == 1 && y.t == 2"),
njs_str("true") },
+ { njs_str("function A(){}; A.tag = 'A'; var a = new A();"
+ "(function B(){}).prototype = A.prototype;"
+ "a.constructor.tag"),
+ njs_str("A") },
+
+ { njs_str("function A(){}; A.tag = 'A'; var a = new A();"
+ "(function B(){}).prototype = a.constructor.prototype;"
+ "a.constructor.tag"),
+ njs_str("A") },
+
{ njs_str("var x = {}, y = function() {}, z; y.prototype = x; z = new y();"
"(z instanceof y) && (z.__proto__ == y.prototype) && (x.isPrototypeOf(z))"),
njs_str("true") },