File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ export default Base.extend({
34
34
return ;
35
35
}
36
36
event . preventDefault ( ) ;
37
- event . stopPropagation ( ) ;
38
37
if ( this . options . delay ) {
39
38
await utils . timeout ( this . options . delay ) ;
40
39
}
Original file line number Diff line number Diff line change @@ -124,5 +124,43 @@ describe("pat-forward", function () {
124
124
await utils . timeout ( 300 ) ;
125
125
expect ( window . location . href . indexOf ( "#oh" ) > - 1 ) . toBe ( true ) ;
126
126
} ) ;
127
+
128
+ it ( "does not steal the click event but let it bubble up." , function ( ) {
129
+ document . body . innerHTML = `
130
+
131
+ <div class="pat-forward" data-pat-forward="#target1">
132
+ <button class="pat-forward" type="button" data-pat-forward="#target2">Button 2</button>
133
+ </div>
134
+
135
+ <div id="target1">Target 1</div>
136
+ <div id="target2">Target 2</div>
137
+ ` ;
138
+
139
+ const source1 = document . querySelector ( "div.pat-forward" ) ;
140
+ const source2 = document . querySelector ( "button.pat-forward" ) ;
141
+
142
+ const target1 = document . querySelector ( "#target1" ) ;
143
+ const target2 = document . querySelector ( "#target2" ) ;
144
+
145
+ let target1_clicks = 0 ;
146
+ target1 . addEventListener ( "click" , ( ) => {
147
+ target1_clicks ++ ;
148
+ } ) ;
149
+
150
+ let target2_clicks = 0 ;
151
+ target2 . addEventListener ( "click" , ( ) => {
152
+ target2_clicks ++ ;
153
+ } ) ;
154
+
155
+ new pattern ( source1 ) ;
156
+ new pattern ( source2 ) ;
157
+
158
+ source1 . click ( ) ;
159
+ expect ( target1_clicks ) . toBe ( 1 ) ;
160
+
161
+ source2 . click ( ) ;
162
+ expect ( target2_clicks ) . toBe ( 1 ) ;
163
+ expect ( target1_clicks ) . toBe ( 2 ) ;
164
+ } ) ;
127
165
} ) ;
128
166
} ) ;
You can’t perform that action at this time.
0 commit comments