W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2010

Re: [WebIDL] interface objects and properties too restrictive?

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 4 Aug 2010 15:58:45 -0700
Message-ID: <AANLkTinCOiWqJqKyyayCxMC-rhDUPfBHTA2MsEwx6cMa@mail.gmail.com>
To: Maciej Stachowiak <mjs@apple.com>
Cc: Travis Leithead <travil@microsoft.com>, Cameron McCormack <cam@mcc.id.au>, "Sam Weinig (weinig@apple.com)" <weinig@apple.com>, public-script-coord@w3.org
Changing the cc to be public-script-coord per Arthur's request.

On Wed, Aug 4, 2010 at 3:42 PM, Maciej Stachowiak <mjs@apple.com> wrote:
> On Aug 4, 2010, at 11:36 AM, Travis Leithead wrote:
>> Sure.
>> Not only does ES5's configurable: false property prevent deletion, but it also prevents changing a property from a field to an accessor and vice-versa, as well as changing the getter/setters of the property.
>> So, the following wouldn't work if the "appendChild" property was configurable:false:
>> Object.defineProperty(Node.prototype,
>>                      "appendChild",
>>                      { get: function() { /* custom getter replacement */ },
>>                        set: function(x) { /* custom setter replacement */ }
>>                      });
>> ... which is the ES5 way of doing:
>> Node.prototype.__defineGetter__("appendChild", function() { /* custom getter replacement */ });
>> Node.prototype.__defineSetter__("appendChild", function(x) { /* custom setter replacement */ });
>> So, configurable: false prevents users from replacing built-in properties with getter/setters. I think this is too restrictive, especially forward-looking considering how much the DOM is changing and evolving.
> I don't see why you would want to do that. The common way to override the behavior of DOM operations is:
> Node.prototype.appendChild = function(node) { /* replacement function */ }


Travis: Is there anything you can't do using this pattern?

Maciej: Can you override getter/setters using this pattern too? For
example could you override the document.body getter or the
.textContent setter?

> I think what you describe is not commonly done, or particularly useful. Furthermore, prototype hacking is primarily used for additions, not replacements, which are not impacted by this at all.

I think replacements happen too, and is something that we need to
support. For example implementing a widget library (a'la XBL) might
want to wrap appendChild or .firstChild.

/ Jonas
Received on Wednesday, 4 August 2010 22:59:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:02 UTC