ajax-hook
ajax-hook copied to clipboard
avoid memory leakage and circular reference
- avoid memory leakage (release
xhr
afterXMLHttpRequest.DONE
) - avoid circular reference
- resolve #116 & resolve #95 -
JSON.stringify
would bypass propertyxhr
Note: since xhr is set to null in config
after xhr.readyState
becomes 4, config.xhr
will be null
in async function inside onResponse
.
onResponse: function(response, handler){
...
const config = response.config;
if(config.xhr.readyState === XMLHttpRequest.DONE){
setTimeout(()=>{
console.log('config.xhr === null', config.xhr===null);
}, 100)
}
...
handler.resolve(response);
}
Combined Distribution Script ajaxhook.js
for Testing (PR 119, 120, 121, 122)
https://cdn.jsdelivr.net/gh/cyfung1031/ajax-hook@1ebe48e08108449669290a226e52fc6fbf7ec9ef/dist/ajaxhook.js