On Wed, Aug 3, 2011 at 8:46 AM, Glenn Maynard <[email protected]> wrote: > On Wed, Aug 3, 2011 at 3:34 AM, Anne van Kesteren <[email protected]> wrote: >> On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. <[email protected]> >> wrote: >>> Hmm, is everything exposed as on* attributes now? If so, then yeah, >>> just do that; no need to mess around with a magic property in the >>> attributes bag. >> >> This would still be magical as it is setting an IDL attribute rather than >> a content attribute. > > What's the difference? I'd expect this: > > a = Element.create("a", {href: "http://link", onclick: function(e) { }, > custom: "value" }, "link"); > > to be essentially equivalent to > > a = document.createElement("a"); > a.appendChild(document.createTextNode("link")); > attrs = {href: "http://link", onclick: function(e) { }, custom: "value" }; > for(key in attrs) a[key] = attrs[key];
Yes, because there you're setting the IDL attributes. Anne's assuming that the intended virtual implementation instead has this as the final line: for(key in attrs) a.setAttribute(key,attrs[key]); This would obviously produce a different result here, as the function would be stringified into something useless. For most attributes, there's no difference between the two approaches, but a handful have significant differences. ~TJ
