Skip to content

Commit 177fbe3

Browse files
committed
netteForms: DOMContentLoaded is never executed when script is loaded asynchronically
1 parent 8d71c5f commit 177fbe3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/assets/netteForms.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
* Attaches a handler to an event for the element.
3939
*/
4040
Nette.addEvent = function(element, on, callback) {
41-
if (element.addEventListener) {
41+
if (on === 'DOMContentLoaded' && element.readyState !== 'loading') {
42+
callback.call(this);
43+
} else if (element.addEventListener) {
4244
element.addEventListener(on, callback);
4345
} else if (on === 'DOMContentLoaded') {
4446
element.attachEvent('onreadystatechange', function() {

0 commit comments

Comments
 (0)