4 ms·
That giant font works for Array.prototype.slice but what about CanvasRenderingContext2D.prototype.createRadialGradient or WebGL2RenderingContext.prototype.getAc
by greggman 9y ago
That giant font works for Array.prototype.slice but what about CanvasRenderingContext2D.prototype.createRadialGradient or WebGL2RenderingContext.prototype.getActiveUniformBlockParameter?
- MikusR 9y agoThe WebGL2RenderingContext.getActiveUniformBlockParameter() fits https://pageshot.net/1pwSmFUZ4hnNcHlJ/developer.mozilla.org https://pageshot.net/1pwSmFUZ4hnNcHlJ/developer.mozilla.org
- greggman 9y agothat's inconsistent with the other Array docs. The correct function is WebGL2RenderingContext.prototype.getActiveUniformBlockParameter() if you're trying to be consistent
- carussell 9y agoArray.prototype.slice is specced out by the JS standard. getActiveUniformBlockParameter is part of the DOM. The DOM is specced in terms of interfaces—the only thing that the DOM guarantees is that when you're interacting with an object that satisfies the interface, it will have a getActiveUniformBlockParameter method. WebGL2RenderingContext.prototype.getActiveUniformBlockParameter is a JS-ism and isn't essential to the implementation of the spec.
- greggman 9y agowhat? it's required that setting WebGL2RenderingContext.prototype.getActiveUniformBlockParameter to some other function work. You set it before object creation. Objects created indirectly get the new functionality through their prototype. This is true for all DOM objects. maybe I don't understand your distinction
- carussell 9y ago> Objects created indirectly get the new functionality through their prototype Except most parts of the DOM in most engines is implemented in C++, not JS. <whatever>.prototype is a JS-ism. But the DOM is not defined in terms of JS. It's defined in terms of a language-agnostic set of interfaces. So when poking around and seeing things like NodeIterator.prototype within JS, you're seeing them because the browser is presenting it to you in a way that kind of resembles the way things work for that runtime. <whatever>.prototype (when <whatever> is some DOM interface) is a byproduct of that behavior. But that those interfaces get implemented is the only essential characteristic of the DOM, and the docs should reflect those interfaces, not the weird and tangential byproducts of how the DOM gets projected into a JS runtime.
- greggman 9y agoI'm not understanding the distinction from a JS programmer's perspective. If I have a = {} a.foo = () => (); foo is a member of a. Where as if I have class A { foo() {} } a = new A(); foo is a member of the prototype for class A. This is important because I need to know if replacing A.prototype.foo will effect all new As or none. Documenting the function is defined on the prototype tells me this. So, I need both Array.prototype.slice and WebGL2RenderingContext.prototype. getActiveUniformBlockParameter documented the same. If WebGL2RenderingContext.prototype.getActiveUniformBlockParameter is only documented as WebGL2RenderingContext.getActiveUniformBlockParameter that suggests to me that I can't do this WebGL2RenderingContext.prototype. getActiveUniformBlockParameter = someNewFunc gl = someCanvas.getContext("webgl2") Instead I must do this gl = someCanvas.getContext("webgl2") gl.getActiveUniformBlockParameter = someNewFunc The first is far more useful because I can effect it indirectly. The second requires me to modified code at creation, code that might be in a 3rd party library. So, if .prototype. is left out of the docs for WebGL2RenderingContext.prototype.getActiveUniformBlockParameter that suggests to me I can't do the first. Seems like those 2 things Array.prototype.slice and WebGL2RenderingContext.prototype.getActiveUniformBlockParameter should be documented consistently. In other words, a JS programmer does not care about implementation details. They don't care one object is a DOM element vs a JS Object (at least not in this case). They care how they can use it in a program. To do that they need to know is the function on the prototype or on the object itself and documenting as Class.prototype.func tells them that.
- amelius 9y agoOfftopic. Why are long lines on HN always clipped with a big margin on narrow screens such as on mobile?