Skip to content

[WebProfilerBundle] Fixes event listener attaching error in IE #13636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,7 @@
}

// attach listener for expanding/collapsing the target
buttons[i].addEventListener('click', function (e) {
toggle(this);

e.preventDefault();
e.stopPropagation();

return false;
});
clickHandler(buttons[i], toggle);

if (states.hasOwnProperty(targetId)) {
// open or collapse based on stored data
Expand Down Expand Up @@ -380,14 +373,7 @@
throw "Tab target " + targetId + " does not exist";
}

tabs[i].addEventListener('click', function (e) {
select(this);

e.preventDefault();
e.stopPropagation();

return false;
});
clickHandler(buttons[i], select);

Sfjs.addClass(target, 'hidden');
}
Expand All @@ -405,7 +391,26 @@
}

var tabTarget = new TabView(),
toggler = new Toggler(new JsonStorage(sessionStorage));
toggler = new Toggler(new JsonStorage(sessionStorage)),
clickHandler = function (element, callback) {
Sfjs.addEventListener(element, 'click', function (e) {
if (!e) {
e = window.event;
}

callback(e.target || e.srcElement);

if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}

e.stopPropagation();

return false;
});
};

tabTarget.initTabs(document.querySelectorAll('.tree .tree-inner'));
toggler.initButtons(document.querySelectorAll('a.toggle-button'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@
requestCounter[0].className = className;
};

var addEventListener;

if (document.addEventListener) {
addEventListener = function (element, eventName, callback) {
element.attachEvent('on' + eventName, callback);
};
} else {
addEventListener = function (element, eventName, callback) {
element.addEventListener(eventName, callback, false);
};
}

{% if excluded_ajax_paths is defined %}
var proxied = XMLHttpRequest.prototype.open;

Expand All @@ -189,7 +201,7 @@

requestStack.push(stackElement);

this.addEventListener("readystatechange", function() {
addEventListener(this, 'readystatechange', function() {
if (self.readyState == 4) {
stackElement.duration = new Date() - stackElement.start;
stackElement.loading = false;
Expand All @@ -199,7 +211,7 @@

Sfjs.renderAjaxRequests();
}
}, false);
});

Sfjs.renderAjaxRequests();
}
Expand All @@ -219,6 +231,8 @@

setPreference: setPreference,

addEventListener: addEventListener,

request: request,

renderAjaxRequests: renderAjaxRequests,
Expand Down