On 5/23/2010 2:35 PM, P T Withington wrote:
On 2010-05-22, at 09:56, André Bargull wrote:

Not yet approved:

1) NodeModel#addHandlerInternal(..):
+              "#beginAttribute\n" +
+              reference + CompilerUtils.endSourceLocationDirective + 
"\n#endAttribute\n);\n" +
+              "if ($debug) {\n" +
+              "  if (! ($lzc$reference is LzEventable)) {\n" +
+              "    Debug.error('Invalid event sender: " + reference + " =>  %w (for event 
" + event + ")', $lzc$reference);\n" +
+              "  }\n" +
+              "}\n" +
+              "return $lzc$reference;\n";

This is now returning $lzc$reference even if it's not a LzEventable, the 
previous code just returned undefined.

But only in debug mode.  In non-debug, it just returned the reference.

Yes, it's only concerning debug-mode. I thought that was obvious, but I still should have mentioned it to avoid any confusion.


It seems to me that debug mode should not change the behavior.  You could argue 
that either behavior is correct, but it seems important for the behavior to be 
consistent.  Unless you have a compelling argument to always enforce the type 
(and return undefined when wrong), I think the current implementation is better 
than the previous.


Neither behaviour is absolutely correct, here's a related test case.
<canvas debug="true">
  <node>
    <handler name="oninit" reference="global">
      Debug.write("oninit")
    </handler>
  </node>
</canvas>

Old behaviour (debug mode, all runtimes):
(1) debug error "ERROR: Invalid event sender: global => global (for event oninit)"
(2) invalid sender is changed to 'this' (see lz.Node#__LZsetDelegates())
(3) handler code is executed because of (2)

New behaviour (debug mode)
(1) debug error "ERROR: Invalid event sender: global => global (for event oninit)" (2 - swf8) delegate for handler registered to invalid sender (for swf8 kernel compatibility, see lz.Delegate and lz.Event) (2 - except swf8) debug error "ERROR: Not registering /anonymous/<handler method='handle global.oninit'>: invalid event sender: global.oninit"


To change to sender is wrong, but to print a warning and still register the delegate resp. print another warning is wrong, too.

Reply via email to