Path: csiph.com!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.214.226.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Object.create(canvas.getContext()) Date: Sun, 12 Nov 2017 17:42:35 +0100 Organization: PointedEars Software (PES) Lines: 34 Message-ID: <5326256.lOV4Wx5bFT@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit Injection-Info: gwaiyur.mb-net.net; posting-host="214.226.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch:178.197.226.214"; logging-data="18418"; mail-complaints-to="abuse@open-news-network.org" User-Agent: KNode/4.14.2 X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. My intention was to create an object that inherits from a specific webgl > context, so that I can populate some (more or less) webgl-related, app- > specific helper functions. > > > gl = Object.create( webglcanvas.getContext("webgl2") ); > > dolog(gl); // prints "[object Object]" > > dolog(gl.__proto__); // prints "[object WebGL2RenderingContext]" > > gl.clearColor(0.7, 0.7, 0.7, 1.0); > > > TypeError: 'clearColor' called on an object that does not implement > interface WebGL2RenderingContext. dolog() is not a built-in function in any ECMAScript implementations that I know. That leaves one to *guess* what *your* dolog(…) does (presumably, “({}).toString.call(…)”.) That you can create an object which inherits from another does not mean that you can use it like the other; this is particulary true of host objects as this one. If subclassing does not work either (or cannot be assumed to be available), create a wrapper object. If available, you can use “Proxy” (ECMAScript 2015+) or “__noSuchMethod__” (Mozilla JavaScript 43+ only, obsolete) to implement seamless access. -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.