mirror of https://github.com/vitalif/phantomjs
Fix bug where WebPage.evaluate had a syntax error.
It now creates a proper anonymous function (which passes this for global context)1.2
parent
0d78768e4d
commit
d2c520a777
|
@ -269,7 +269,7 @@ class WebPage(QObject):
|
|||
|
||||
@pyqtSlot(str, result='QVariant')
|
||||
def evaluate(self, code):
|
||||
function = '(%s)()' % code
|
||||
function = '(function(){%s}).call(this);' % code
|
||||
return self.m_mainFrame.evaluateJavaScript(function)
|
||||
|
||||
@pyqtSlot(str, str, 'QVariantMap')
|
||||
|
|
|
@ -209,7 +209,7 @@ QVariantMap WebPage::paperSize() const
|
|||
|
||||
QVariant WebPage::evaluate(const QString &code)
|
||||
{
|
||||
QString function = "(" + code + ")()";
|
||||
QString function = "(function(){" + code + "}).call(this);";
|
||||
return m_mainFrame->evaluateJavaScript(function);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue