n-api: fix inheritance
In napi_define_class()
we assign prototype properties to InstanceTemplate
. This seems to cause an Illegal invocation
exception when attempting to call a method on an object which is inherited from its parent class.
OTOH if we retrieve the "prototype"
property of the class and assign prototype properties to the resulting object, following the prototype chain and retrieving the method and invoking it from the parent class' prototype works.
This problem has been discussed in https://github.com/nodejs/node-addon-api/issues/246.
Should there be a distinction between assigning properties to a FunctionTemplate
's InstanceTemplate
and to the object residing at the resulting function's "prototype"
property?
@TimothyGu @hashseed what do you think?
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines