[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    JS return values
From:       David Faure <david () mandrakesoft ! com>
Date:       2001-02-28 20:45:27
[Download RAW message or body]

ecma/kjs_window.cpp :
655       return Completion(Normal, result);

kjs/function.cpp :
128       else if (comp.complType() == ReturnValue)
129         return comp.value();
130       else
131         return Undefined();

This obviously makes any window function return Undefined :(

So I can easily fix my "blah=window.open" problem this way :

Index: kjs_window.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.99
diff -u -p -r1.99 kjs_window.cpp
--- kjs_window.cpp      2001/02/23 01:50:49     1.99
+++ kjs_window.cpp      2001/02/28 20:43:28
@@ -532,7 +532,7 @@ Completion WindowFunc::tryExecute(const
            if (uargs.frameName == "_blank")
               uargs.frameName = QString::null;
            emit static_cast<KHTMLPart*>(newPart)->browserExtension()->openURLRequest(url,uargs);
-           result = win;
+           return Completion( ReturnValue, win );
         } else
             result = Undefined();
      }

Harri, what's the more generic solution ?
Should we do like the above in every Window function that should return a value,
or should we simply fix line 655 to s/Normal/ReturnValue/, given that if the value
is undefined, kjs/function is going to return Undefined anyway ?

There has to be a reason for Normal vs ReturnValue but I'm probably missing it :-)

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://perso.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic