This repository was archived by the owner on Feb 17, 2021. It is now read-only.
File tree 2 files changed +24
-8
lines changed
2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 1193
1193
if ( callouts [ opt . id ] ) {
1194
1194
throw new Error ( 'Callout by that id already exists. Please choose a unique id.' ) ;
1195
1195
}
1196
+ if ( ! utils . getStepTarget ( opt ) ) {
1197
+ throw new Error ( 'Must specify existing target element via \'target\' option.' ) ;
1198
+ }
1196
1199
opt . showNextButton = opt . showPrevButton = false ;
1197
1200
opt . isTourBubble = false ;
1198
1201
callout = new HopscotchBubble ( opt ) ;
1199
1202
callouts [ opt . id ] = callout ;
1200
1203
calloutOpts [ opt . id ] = opt ;
1201
- if ( opt . target ) {
1202
- callout . render ( opt , null , function ( ) {
1203
- callout . show ( ) ;
1204
- if ( opt . onShow ) {
1205
- utils . invokeCallback ( opt . onShow ) ;
1206
- }
1207
- } ) ;
1208
- }
1204
+ callout . render ( opt , null , function ( ) {
1205
+ callout . show ( ) ;
1206
+ if ( opt . onShow ) {
1207
+ utils . invokeCallback ( opt . onShow ) ;
1208
+ }
1209
+ } ) ;
1209
1210
}
1210
1211
else {
1211
1212
throw new Error ( 'Must specify a callout id.' ) ;
Original file line number Diff line number Diff line change @@ -1016,6 +1016,21 @@ describe('Hopscotch', function() {
1016
1016
1017
1017
hopscotch . endTour ( ) ;
1018
1018
} ) ;
1019
+
1020
+ it ( 'should throw an exception when stand-alone callout target does not exist' , function ( ) {
1021
+ var calloutMgr = hopscotch . getCalloutManager ( ) ;
1022
+ expect ( function ( ) {
1023
+ calloutMgr . createCallout ( {
1024
+ id : 'hopscotch-callout-test-123' ,
1025
+ target : 'totally-does-not-exist' ,
1026
+ placement : 'bottom' ,
1027
+ title : 'This test is fun!' ,
1028
+ content : 'This is how we test this library!'
1029
+ } ) ;
1030
+ } ) . toThrow ( new Error ( 'Must specify existing target element via \'target\' option.' ) ) ;
1031
+
1032
+ } ) ;
1033
+
1019
1034
} ) ;
1020
1035
1021
1036
describe ( 'Saving state' , function ( ) {
You can’t perform that action at this time.
0 commit comments