Wrap userscripts in an anonymous function.

This commit is contained in:
Christian Dywan 2008-05-04 01:34:39 +02:00
parent e45fe65278
commit 5b731c45ba
1 changed files with 4 additions and 1 deletions

View File

@ -521,8 +521,11 @@ _js_document_load_script_file (JSContextRef js_context,
GError* error = NULL;
if (g_file_get_contents (filename, &script, NULL, &error))
{
if (_js_eval (js_context, script, exception))
gchar* wrapped_script = g_strdup_printf (
"var wrapped = function () { %s }; wrapped ();", script);
if (_js_eval (js_context, wrapped_script, exception))
result = TRUE;
g_free (wrapped_script);
g_free (script);
}
else