File tree 3 files changed +36
-1
lines changed
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -228,12 +228,20 @@ ionic.tap = {
228
228
} ,
229
229
230
230
requiresNativeClick : function ( ele ) {
231
- if ( ! ele || ele . disabled || ( / ^ ( f i l e | r a n g e ) $ / i) . test ( ele . type ) || ( / ^ ( o b j e c t | v i d e o ) $ / i) . test ( ele . tagName ) ) {
231
+ if ( ! ele || ele . disabled || ( / ^ ( f i l e | r a n g e ) $ / i) . test ( ele . type ) || ( / ^ ( o b j e c t | v i d e o ) $ / i) . test ( ele . tagName ) || ionic . tap . isLabelContainingFileInput ( ele ) ) {
232
232
return true ;
233
233
}
234
234
return ionic . tap . isElementTapDisabled ( ele ) ;
235
235
} ,
236
236
237
+ isLabelContainingFileInput : function ( ele ) {
238
+ var lbl = tapContainingElement ( ele ) ;
239
+ if ( lbl . tagName !== 'LABEL' ) return false ;
240
+ var fileInput = lbl . querySelector ( 'input[type=file]' ) ;
241
+ if ( fileInput && fileInput . disabled === false ) return true ;
242
+ return false ;
243
+ } ,
244
+
237
245
isElementTapDisabled : function ( ele ) {
238
246
if ( ele && ele . nodeType === 1 ) {
239
247
var element = ele ;
Original file line number Diff line number Diff line change 168
168
< option > United States</ option >
169
169
</ select >
170
170
</ div >
171
+ < div class ="item item-divider ">
172
+ File Input
173
+ </ div >
174
+ < label class ="item item-input ">
175
+ < div class ="input-label ">
176
+ < i class ="icon ion-document-text "> </ i > File
177
+ </ div >
178
+ < input type ="file "/>
179
+ </ label >
171
180
172
181
< div class ="item item-divider ">
173
182
Other Tests
Original file line number Diff line number Diff line change @@ -746,6 +746,24 @@ describe('Ionic Tap', function() {
746
746
expect ( ionic . tap . requiresNativeClick ( div5 ) ) . toEqual ( true ) ;
747
747
} ) ;
748
748
749
+ it ( 'Should ionic.tap.requiresNativeClick for labels containing input[file]' , function ( ) {
750
+ var lbl = document . createElement ( 'label' ) ;
751
+ var ele = document . createElement ( 'input' ) ;
752
+ ele . type = 'file' ;
753
+ lbl . appendChild ( ele ) ;
754
+ expect ( ionic . tap . requiresNativeClick ( lbl ) ) . toEqual ( true ) ;
755
+ } ) ;
756
+
757
+ it ( 'Should ionic.tap.requiresNativeClick for elements underneath labels containing input[file]' , function ( ) {
758
+ var lbl = document . createElement ( 'label' ) ;
759
+ var txt = document . createElement ( 'span' ) ;
760
+ var ele = document . createElement ( 'input' ) ;
761
+ ele . type = 'file' ;
762
+ lbl . appendChild ( ele ) ;
763
+ lbl . appendChild ( txt ) ;
764
+ expect ( ionic . tap . requiresNativeClick ( txt ) ) . toEqual ( true ) ;
765
+ } ) ;
766
+
749
767
it ( 'Should not allow a click that has an textarea target but not created by tapClick' , function ( ) {
750
768
var e = {
751
769
target : document . createElement ( 'textarea' ) ,
You can’t perform that action at this time.
0 commit comments