ref: c85c45eebe0bf9a24106391abfe7d666e471dd1c
parent: 4ee7ef822d1b38c0293f575517d2dd9cf6863c7f
author: Tor Andersson <tor@ccxvii.net>
date: Sat Jan 25 12:59:15 EST 2014
Create variables as DontDelete and DontEnum. This is only for variables declared with the 'var' keyword, function declarations and function parameters. Assignment to an undefined variable still creates a regular property on the global object.
--- a/jsrun.c
+++ b/jsrun.c
@@ -447,7 +447,7 @@
static void js_decvar(js_State *J, const char *name, int idx)
{
- jsR_setproperty(J, J->E->variables, name, idx);
+ jsR_defproperty(J, J->E->variables, name, idx, JS_DONTENUM | JS_DONTDELETE);
}
static void js_getvar(js_State *J, const char *name)
@@ -485,7 +485,6 @@
{
js_Environment *E = J->E;
do {
- // TODO: does delete follow prototype chain?
js_Property *ref = jsV_getownproperty(J, E->variables, name);
if (ref) {
if (ref->atts & JS_DONTDELETE)