@@ -146,6 +146,37 @@ describe("intro", () => {
146
146
) ;
147
147
} ) ;
148
148
149
+ test ( "should find added later element" , ( ) => {
150
+ const latterAddedElId = "later_added" ;
151
+ var laterAddedEl ;
152
+ var stepCounter = 0 ;
153
+ const intro = introJs ( )
154
+ . setOptions ( {
155
+ steps : [
156
+ {
157
+ intro : "step one" ,
158
+ } ,
159
+ {
160
+ intro : "later aded" ,
161
+ element : "#" + latterAddedElId ,
162
+ } ,
163
+ ] ,
164
+ } )
165
+ . onchange ( function ( el ) {
166
+ if ( el && stepCounter === 1 ) expect ( el ) . toBe ( laterAddedEl ) ;
167
+ stepCounter ++ ;
168
+ } )
169
+ . start ( ) ;
170
+
171
+ laterAddedEl = appendDummyElement ( ) ;
172
+ laterAddedEl . setAttribute ( "id" , latterAddedElId ) ;
173
+
174
+ intro . nextStep ( ) ;
175
+ const step = intro . currentStep ( ) ;
176
+ expect ( step ) . toBe ( 1 ) ;
177
+ expect ( intro . _introItems [ step ] . element ) . toBe ( laterAddedEl ) ;
178
+ } ) ;
179
+
149
180
test ( "should highlight the target element" , ( ) => {
150
181
const p = appendDummyElement ( ) ;
151
182
@@ -164,6 +195,34 @@ describe("intro", () => {
164
195
expect ( p . className ) . toContain ( "introjs-relativePosition" ) ;
165
196
} ) ;
166
197
198
+ test ( "should highlight added later target element" , ( done ) => {
199
+ const latterAddedElId = "later_added" ;
200
+ const intro = introJs ( )
201
+ . setOptions ( {
202
+ steps : [
203
+ {
204
+ intro : "step one" ,
205
+ } ,
206
+ {
207
+ intro : "later added" ,
208
+ element : "#" + latterAddedElId ,
209
+ } ,
210
+ ] ,
211
+ } )
212
+ . start ( ) ;
213
+
214
+ const laterAdded = appendDummyElement ( ) ;
215
+ laterAdded . setAttribute ( "id" , latterAddedElId ) ;
216
+
217
+ intro . nextStep ( ) ;
218
+ setTimeout ( ( ) => {
219
+ // Waiting for animation for avoiding error
220
+ expect ( laterAdded . className ) . toContain ( "introjs-showElement" ) ;
221
+ expect ( laterAdded . className ) . toContain ( "introjs-relativePosition" ) ;
222
+ done ( ) ;
223
+ } , 500 ) ;
224
+ } ) ;
225
+
167
226
test ( "should not highlight the target element if queryString is incorrect" , ( ) => {
168
227
const p = appendDummyElement ( ) ;
169
228
0 commit comments