From e14bdef514b4e2fe5cd42fec0284f96bcc988a3e Mon Sep 17 00:00:00 2001 From: "mhammond%skippinet.com.au" Date: Mon, 10 Oct 2005 10:02:05 +0000 Subject: [PATCH] Add comments, remove prints, change repr(), and support event functions not declaring some/all params. git-svn-id: svn://10.0.0.236/branches/DOM_AGNOSTIC_BRANCH@181898 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/python/dom/nsdom/context.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mozilla/extensions/python/dom/nsdom/context.py b/mozilla/extensions/python/dom/nsdom/context.py index 9c267f79031..91a1b248613 100644 --- a/mozilla/extensions/python/dom/nsdom/context.py +++ b/mozilla/extensions/python/dom/nsdom/context.py @@ -69,17 +69,16 @@ class WrappedNative(Component): try: Component.__setattr__(self, attr, value) except AttributeError: - # Set it as an 'expando' + # Set it as an 'expando'. It looks like we should delegate *all* + # to the outside object. logger.debug("%s set expando property %r=%r for object %r", self, attr, value, self._comobj_) # and register if an event. if attr.startswith("on"): # I'm quite confused by this :( target = self._comobj_ - print "target was", target if _nsdom.IsOuterWindow(target): target = _nsdom.GetCurrentInnerWindow(target) - print "target now", target go = self._context_.globalObject scope = self._context_.GetNativeGlobal() if callable(value): @@ -106,10 +105,8 @@ class WrappedNative(Component): class WrappedNativeGlobal(WrappedNative): # Special support for our global. def __repr__(self): - return "" % _nsdom.IsOuterWindow(self._comobj_) - - - pass + return "" % (_nsdom.IsOuterWindow(self._comobj_), + self._comobj_) class ScriptContext: def __init__(self): @@ -244,6 +241,8 @@ class ScriptContext: # new globals f = new.function(handler.func_code, globs, handler.func_name) args = tuple(self._fixArg(argv)) + # We support having less args declared than supplied, a-la JS. + args = args[:handler.func_code.co_argcount] return f(*args) def BindCompiledEventHandler(self, target, scope, name, handler): @@ -269,7 +268,8 @@ class ScriptContext: try: return ns[name] except KeyError: - logger.info("Event handler %s not found in my namespace - checking scope") + logger.info("Event handler %s not found in my namespace - checking scope", + name) return scope[name] def SetProperty(self, target, name, value):