File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -662,7 +662,11 @@ const inject = {
662
662
663
663
// clean up
664
664
cfgs . forEach ( ( cfg ) => {
665
- if ( "$injected" in cfg ) cfg . $injected . remove ( ) ;
665
+ if ( "$injected" in cfg ) {
666
+ cfg . $injected . remove ( ) ;
667
+ }
668
+ cfg . $target . removeClass ( cfg . loadingClass ) ;
669
+ $el . removeClass ( cfg . executingClass ) ;
666
670
} ) ;
667
671
$el . off ( "pat-ajax-success.pat-inject" ) ;
668
672
$el . off ( "pat-ajax-error.pat-inject" ) ;
Original file line number Diff line number Diff line change @@ -1095,6 +1095,38 @@ describe("pat-inject", function () {
1095
1095
delete global . fetch ;
1096
1096
} ) ;
1097
1097
1098
+ it ( "Removes loading and executing classes." , async ( ) => {
1099
+ document . body . innerHTML = `
1100
+ <a
1101
+ class="pat-inject i-am-executing"
1102
+ href="test.html"
1103
+ >link</a>
1104
+ <div id="someid" class="i-am-loading" />
1105
+ ` ;
1106
+
1107
+ $a = $ ( ".pat-inject" ) ;
1108
+ pattern . init ( $a ) ;
1109
+
1110
+ // Invoke error case
1111
+ pattern . _onInjectError (
1112
+ $a ,
1113
+ [
1114
+ {
1115
+ $target : $ ( "#someid" ) ,
1116
+ loadingClass : "i-am-loading" ,
1117
+ executingClass : "i-am-executing" ,
1118
+ } ,
1119
+ ] ,
1120
+ {
1121
+ jqxhr : { status : 404 } ,
1122
+ }
1123
+ ) ;
1124
+ await utils . timeout ( 1 ) ; // wait a tick for async to settle.
1125
+
1126
+ expect ( document . querySelector ( ".pat-inject" ) . getAttribute ( "class" ) ) . toEqual ( "pat-inject" ) ; // prettier-ignore
1127
+ expect ( document . querySelector ( "#someid" ) . getAttribute ( "class" ) ) . toEqual ( "" ) ;
1128
+ } ) ;
1129
+
1098
1130
it ( "Doesnt get error page from meta tags if query string present" , async ( ) => {
1099
1131
delete global . window . location ;
1100
1132
global . window . location = {
You can’t perform that action at this time.
0 commit comments