Re: [WebIDL] ES3.1 'flexible' attribute and 'delete' semantics

On Thu, Aug 14, 2008 at 4:59 PM, Cameron McCormack <cam@mcc.id.au> wrote:
>
> Hi Garrett.
>
> Travis Leithead:
>> > My question, once again, is whether WebIDL will define exactly how
>> > to translate the behavior of operators like delete into the
>> > JavaScript language binding for DOM objects.
>
> Garrett Smith:
>> That isn't a question. This is: Why does WebIDL need to define how
>> delete works on Document.prototype.getElementById? There is no
>> guarantee that Document will be an object, or that Document.prototype
>> will be the [[Prototype]] of document. Nor should there be.
>
> Web IDL wouldn't specifically say "delete works on
> Document.prototype.getElementById", but I think it should say how these
> kinds of objects (Document, Document's [[Prototype]]) behave, e.g.
> "a property on an interface prototype object that corresponds to an IDL
> operation has attributes { DontEnum }".  JS libraries do exploit the
> prototype chain to add methods etc.,

Yes, there have been libraries that have made this mistake.

> so it would be good if they could
> do this with the blessing of a spec,

No, it would only encourage such design.

You'll see things like:

HTMLElement.prototype.dispatchEvent = function(e){
// ...
};

and then
if(extendedByLibrary)
  el.dispatchEvent(event);

The HTMLElement in one frame might not be the same as HTMLElement in
the other; that would seem to be a potential cross frame security
issue.

> rather than de factor behaviour.
> Given MS's interest in following Web IDL, there's a chance we could get
> all four browsers doing the same thing, too.

Document interface is an interface. An interface does not have defined
implementation; it is merely a contract. "IDL" is for "Interface
Definition".

The fact that some browsers expose Document as a global property does
not need standardization. It would not be bad to have DOM readonly
properties implemented with [[DontDelete]], [[ReadOnly]]. That could
be one line in WebIDL, e.g.

"DOM readonly properties have [[DontDelete]] and [[ReadOnly]]."

But it seems fairly obvious that this would have to be so, so it
wouldn't seem critical to include that.

Garrett

> --
> Cameron McCormack ≝ http://mcc.id.au/
>
>

Received on Friday, 15 August 2008 01:11:25 UTC