Skip to content

Commit

Permalink
netteForms: DOMContentLoaded is never executed when script is loaded …
Browse files Browse the repository at this point in the history
…asynchronically
  • Loading branch information
dg committed Jun 28, 2018
1 parent 8d71c5f commit 177fbe3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/assets/netteForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
* Attaches a handler to an event for the element.
*/
Nette.addEvent = function(element, on, callback) {
if (element.addEventListener) {
if (on === 'DOMContentLoaded' && element.readyState !== 'loading') {
callback.call(this);
} else if (element.addEventListener) {
element.addEventListener(on, callback);
} else if (on === 'DOMContentLoaded') {
element.attachEvent('onreadystatechange', function() {
Expand Down

0 comments on commit 177fbe3

Please sign in to comment.