- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Thu, 16 Feb 2012 10:50:12 -0500
- To: public-script-coord@w3.org
On 2/16/12 10:46 AM, Marcos Caceres wrote:
> The WebIDL spec warns against using [TreatNonCallableAsNull] "unless required to specify the behavior of legacy APIs", but does not provide guidance on what to do in a situation where an Editor might need such a thing
If you're writing IDL for something that's already in the wild with this
behavior, you need it.
If you're writing a spec for something new, you don't.
> Can you please add some more text to the warning saying what the alternative is
Just don't use the extended attribute.
> Interface SomeThing : EventTarget{
> [TreatNonCallableAsNull] attribute SomeCallBack? onclose;
> }
>
> So I could have both:
>
> window.something.onclose = function(){ ... }
> window.something.addEventListener("close"….)
You don't need the extended attribute for that. That will just work.
What you need [TreatNonCallableAsNull] is if you want this:
window.something.onclose = 5;
or
window.something.onclose = "monkeypants";
to just silently remove the event handler, if any, set via onclose
before instead of throwing an exception.
For new specs, it seems like throwing an exception would be preferable,
right?
-Boris
Received on Thursday, 16 February 2012 15:50:39 UTC