[Pkg-javascript-commits] [dojo] 75/88: Fixes circular reference between promises. (1.8 backport) !strict refs #16794
David Prévot
taffit at moszumanska.debian.org
Thu Aug 21 17:39:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 1.8.5
in repository dojo.
commit 59fc5e57900bf24a8d459496f9d2b1a9a8abbec6
Author: Bryan Forbes <bryan at reigndropsfall.net>
Date: Sat Mar 23 20:31:12 2013 +0000
Fixes circular reference between promises. (1.8 backport) !strict refs #16794
git-svn-id: http://svn.dojotoolkit.org/src/branches/1.8/dojo@30993 560b804f-0ae3-0310-86f3-f6aa0a117693
---
request/util.js | 31 ++++++++++++++++++++++---------
request/xhr.js | 11 +++++++----
2 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/request/util.js b/request/util.js
index 7dac994..86a9b42 100644
--- a/request/util.js
+++ b/request/util.js
@@ -5,8 +5,9 @@ define([
'../Deferred',
'../io-query',
'../_base/array',
- '../_base/lang'
-], function(exports, RequestError, CancelError, Deferred, ioQuery, array, lang){
+ '../_base/lang',
+ '../promise/Promise'
+], function(exports, RequestError, CancelError, Deferred, ioQuery, array, lang, Promise){
exports.deepCopy = function deepCopy(target, source){
for(var name in source){
var tval = target[name],
@@ -41,6 +42,9 @@ define([
function okHandler(response){
return freeze(response);
}
+ function dataHandler (response) {
+ return response.data || response.text;
+ }
exports.deferred = function deferred(response, cancel, isValid, isReady, handleResponse, last){
var def = new Deferred(function(reason){
@@ -70,13 +74,22 @@ define([
);
}
- var dataPromise = responsePromise.then(function(response){
- return response.data || response.text;
- });
-
- var promise = freeze(lang.delegate(dataPromise, {
- response: responsePromise
- }));
+ var dataPromise = responsePromise.then(dataHandler);
+
+ // http://bugs.dojotoolkit.org/ticket/16794
+ // The following works around a leak in IE9 through the
+ // prototype using lang.delegate on dataPromise and
+ // assigning the result a property with a reference to
+ // responsePromise.
+ var promise = new Promise();
+ for (var prop in dataPromise) {
+ if (dataPromise.hasOwnProperty(prop)) {
+ promise[prop] = dataPromise[prop];
+ }
+ }
+ promise.response = responsePromise;
+ freeze(promise);
+ // End leak fix
if(last){
diff --git a/request/xhr.js b/request/xhr.js
index ad8a53b..647c2ec 100644
--- a/request/xhr.js
+++ b/request/xhr.js
@@ -77,7 +77,7 @@ define([
}
function onError(evt){
var _xhr = evt.target;
- var error = new RequestError('Unable to load ' + response.url + ' status: ' + _xhr.status, response);
+ var error = new RequestError('Unable to load ' + response.url + ' status: ' + _xhr.status, response);
dfd.handleResponse(response, error);
}
@@ -97,6 +97,7 @@ define([
_xhr.removeEventListener('load', onLoad, false);
_xhr.removeEventListener('error', onError, false);
_xhr.removeEventListener('progress', onProgress, false);
+ _xhr = null;
};
};
}else{
@@ -117,6 +118,10 @@ define([
};
}
+ function getHeader(headerName){
+ return this.xhr.getResponseHeader(headerName);
+ }
+
var undefined,
defaultOptions = {
data: null,
@@ -156,9 +161,7 @@ define([
return returnDeferred ? dfd : dfd.promise;
}
- response.getHeader = function(headerName){
- return this.xhr.getResponseHeader(headerName);
- };
+ response.getHeader = getHeader;
if(addListeners){
remover = addListeners(_xhr, dfd, response);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list