- From: Marcos Caceres <w3c@marcosc.com>
- Date: Wed, 29 Feb 2012 18:37:46 +0000
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: www-dom@w3.org
On Wednesday, February 29, 2012 at 6:15 PM, Boris Zbarsky wrote: > On 2/29/12 10:05 AM, Marcos Caceres wrote: > > 1. Have an object inherits EventTarget. > > > > Inherits in what sense? What does this mean in practice? In the sense that say: 1. given "var a = { }" 2. … some magic… e.g., EventListener.create( a ); 3. would have .addEventListener(), .removeEventListener(), .dispatchEvent() as properties attached. (I won't pretend to use the right ECMAScript terminology here… be it the prototype chain or whatever) So, you get an Object that has a __proto__ with properties: constructor: function Object() { [native code] } hasOwnProperty: function hasOwnProperty() { [native code] } isPrototypeOf: function isPrototypeOf() { [native code] } propertyIsEnumerable: function propertyIsEnumerable() { [native code] } toLocaleString: function toLocaleString() { [native code] } toString: function toString() { [native code] } valueOf: function valueOf() { [native code] } addEventListener: function addEventListener() { [native code] } removeEventListener: function removeEventListener() { [native code] } dispatchEvent: function dispatchEvent() { [native code] } or something… Hopefully you can understand what I mean from the above. > > You are right, there isn't a practical/technical advantage to creating an element > > It might be much faster (and almost certainly is more memory efficient) > to create a small EventTarget implementation than to create an element. True. -- Marcos Caceres
Received on Wednesday, 29 February 2012 18:38:21 UTC