I think it doesnt has any relation to your error, but the code: var client = new XMLHttpRequest, has a 'new' keyword before the XMLHttpRequest function. But there are no parenthesis after the function name. What you are trying to do with this?
On Fri, Feb 25, 2011 at 4:12 PM, Luis <[email protected]> wrote: > Google Chrome: 10.0.648.119 (Official Build 75907) beta > V8: 3.0.12.24 > > I have a problem where some identical calls to a function create > different results, but the function makes no changes to the > environment that should persist between calls or affect their results. > Shouldn't the results be the same? I use an ECMAScript file 'test.es' > and an XHTML file to load it (included at the end). > > Steps to produce this result: > Load 'test.es' in Google Chrome. > Open the JavaScript Console. > Enter 'submit(client)' and read output 'fresh true'. > Enter 'submit(client)' again and read output 'fresh false'. > > Observations: > An anonymous closure the 'submit' function defines appears to retain > the value variable 'fresh' binds to from a previous call. However, > 'submit' sets 'fresh' and creates a new closure on each call. > Moreover, both outputs read 'fresh true' when I replace 'client' with > 'client0', so the behavior depends on some factor. > > Questions: > Shouldn't the results for the identical calls be identical? > Why are the results identical for calls to 'client0' and not 'client'? > Is this a bug? > > test.es: > function submit(client) { > var fresh = true, uri = ''; > client.fetch(uri, > function () { > console.debug('fresh', fresh), > fresh = false, > delete this.onreadystatechange; > }); > } > var client = new XMLHttpRequest, client0 = {fetch : function (uri, > continuation) {var self = this; > > setTimeout(function () {continuation.call(self);}, 0);}}; > if (!client.DONE) > XMLHttpRequest.prototype.DONE = 4; > client.fetch = function (uri, continuation) { > /* sets this to request resource at uri and dispatch continuation > on acquisition > a continuation error forces continued request until > continuation succeeds or a fatal error occurs */ > this.onreadystatechange = function (event) { > if (this.readyState == this.DONE) { > try {continuation.call(this, event);} > catch (error) { > if (error.fail) > this.requestURI(uri); > else > debugger; > } > } > }, > this.requestURI(uri); > }, > client.requestURI = function(uri) { > this.open('GET', uri), > this.send(); > }; > > The XHTML file: > <html xmlns='http://www.w3.org/1999/xhtml'> > <head> > <meta http-equiv='Content-Script-Type' content='application/ > ecmascript' /> > <script src='test.es' type='application/ecmascript' /> > </head> > <body /> > </html> > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- Luis Otavio de Colla Furquim Não alimente os pingos Don't feed the tribbles - http://www.thinkgeek.com/geektoys/plush/ac6e/ By the nice edges of dataly graphs I shall walk http://www.furquim.org/chironfs/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
