mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Log error if addEventListener called with null fn
This commit is contained in:
parent
1fbc166226
commit
03818bd3e8
3 changed files with 17 additions and 1 deletions
|
@ -1161,6 +1161,7 @@ var fireEvent = function ( type, event ) {
|
||||||
obj( event );
|
obj( event );
|
||||||
}
|
}
|
||||||
} catch ( error ) {
|
} catch ( error ) {
|
||||||
|
error.details = 'Squire: fireEvent error. Event type: ' + type;
|
||||||
editor.didError( error );
|
editor.didError( error );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1173,6 +1174,13 @@ var propagateEvent = function ( event ) {
|
||||||
|
|
||||||
var addEventListener = function ( type, fn ) {
|
var addEventListener = function ( type, fn ) {
|
||||||
var handlers = events[ type ];
|
var handlers = events[ type ];
|
||||||
|
if ( !fn ) {
|
||||||
|
editor.didError({
|
||||||
|
name: 'Squire: addEventListener with null or undefined fn',
|
||||||
|
message: 'Event type: ' + type
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( !handlers ) {
|
if ( !handlers ) {
|
||||||
handlers = events[ type ] = [];
|
handlers = events[ type ] = [];
|
||||||
if ( !customEvents[ type ] ) {
|
if ( !customEvents[ type ] ) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -82,6 +82,7 @@ var fireEvent = function ( type, event ) {
|
||||||
obj( event );
|
obj( event );
|
||||||
}
|
}
|
||||||
} catch ( error ) {
|
} catch ( error ) {
|
||||||
|
error.details = 'Squire: fireEvent error. Event type: ' + type;
|
||||||
editor.didError( error );
|
editor.didError( error );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +95,13 @@ var propagateEvent = function ( event ) {
|
||||||
|
|
||||||
var addEventListener = function ( type, fn ) {
|
var addEventListener = function ( type, fn ) {
|
||||||
var handlers = events[ type ];
|
var handlers = events[ type ];
|
||||||
|
if ( !fn ) {
|
||||||
|
editor.didError({
|
||||||
|
name: 'Squire: addEventListener with null or undefined fn',
|
||||||
|
message: 'Event type: ' + type
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( !handlers ) {
|
if ( !handlers ) {
|
||||||
handlers = events[ type ] = [];
|
handlers = events[ type ] = [];
|
||||||
if ( !customEvents[ type ] ) {
|
if ( !customEvents[ type ] ) {
|
||||||
|
|
Loading…
Reference in a new issue