Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34321
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Object.create(canvas.getContext()) |
| Date | 2017-11-12 17:42 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <5326256.lOV4Wx5bFT@PointedEars.de> (permalink) |
| References | <ou96ju$mvd$1@gwaiyur.mb-net.net> |
Jan Bruns wrote:
> 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: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Object.create(canvas.getContext()) Jan Bruns <ebay@abnuto.de> - 2017-11-12 10:09 +0000
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-12 17:42 +0100
Re: Object.create(canvas.getContext()) Jan Bruns <ebay@abnuto.de> - 2017-11-14 11:48 +0000
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-15 02:32 +0100
Re: Object.create(canvas.getContext()) Jan Bruns <ebay@abnuto.de> - 2017-11-17 20:25 +0000
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-19 05:48 +0100
Re: Object.create(canvas.getContext()) Jan Bruns <ebay@abnuto.de> - 2017-11-19 21:39 +0000
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-19 23:34 +0100
Re: Object.create(canvas.getContext()) Jan Bruns <ebay@abnuto.de> - 2017-11-20 14:47 +0000
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-21 04:07 +0100
Re: Object.create(canvas.getContext()) Jan Bruns <ebay@abnuto.de> - 2017-11-21 16:23 +0000
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-22 04:12 +0100
Re: Object.create(canvas.getContext()) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-11-12 18:45 +0100
csiph-web