summaryrefslogtreecommitdiff
path: root/addons/web/static/lib/qweb/qweb2.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2016-01-26 14:20:54 +0100
committerGéry Debongnie <ged@odoo.com>2016-01-26 14:22:56 +0100
commit06e583e1fde6da956a5126cae246e0e1a3d6d69c (patch)
tree92da4713b97b74e44ee321dc6d67692a986fff72 /addons/web/static/lib/qweb/qweb2.js
parent31efb0c19882aaf977e377851237bf35da4de2c2 (diff)
[FIX] web: change qweb to work around phantomjs bug
This commit does not actually fix qweb2.js, but it works around a phantomjs bug. The problem with phantomjs is that in some situations, the xmlhttprequests are dropped with a status 0. It is most likely related to the issue: https://github.com/ariya/phantomjs/issues/11195 In our testing framework, it seems to appear when requests sent before the 'load' event of phantomjs are received after, and also when those requests are listened with the onreadystatechange handler. The bug does not appear if we use addEventListener with the 'load' event (at least, not for a few builds) This commit does not worsen qweb, and it is also a small improvement in style (in my opinion).
Diffstat (limited to 'addons/web/static/lib/qweb/qweb2.js')
-rw-r--r--addons/web/static/lib/qweb/qweb2.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js
index ee1876d9f4f..1cfc7bb69ef 100644
--- a/addons/web/static/lib/qweb/qweb2.js
+++ b/addons/web/static/lib/qweb/qweb2.js
@@ -295,15 +295,13 @@ QWeb2.Engine = (function() {
}
req.open('GET', s, async);
if (async) {
- req.onreadystatechange = function() {
- if (req.readyState == 4) {
- if (req.status == 200) {
- callback(null, self._parse_from_request(req));
- } else {
- callback(new Error("Can't load template " + s + ", http status " + req.status));
- }
+ req.addEventListener("load", function() {
+ if (req.status == 200) {
+ callback(null, self._parse_from_request(req));
+ } else {
+ callback(new Error("Can't load template " + s + ", http status " + req.status));
}
- };
+ });
}
req.send(null);
if (!async) {