Skip to content

Commit

Permalink
(/^(select|option)$/i).test(e.target.tagName) has been repeated 3 tim…
Browse files Browse the repository at this point in the history
…es in the code so I thought it'd be better to export it in its own helper function isSelectOrOption(tagName)
  • Loading branch information
emonidi committed Jul 29, 2015
1 parent bab6cad commit a017dfe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function tapMouseDown(e) {
console.log('mousedown', 'stop event');
e.stopPropagation();

if ((!ionic.tap.isTextInput(e.target) || tapLastTouchTarget !== e.target) && !(/^(select|option)$/i).test(e.target.tagName)) {
if ((!ionic.tap.isTextInput(e.target) || tapLastTouchTarget !== e.target) && !isSelectOrOption(e.target.tagName)) {
// If you preventDefault on a text input then you cannot move its text caret/cursor.
// Allow through only the text input default. However, without preventDefault on an
// input the 300ms delay can change focus on inputs after the keyboard shows up.
Expand All @@ -379,7 +379,7 @@ function tapMouseUp(e) {
return false;
}

if (tapIgnoreEvent(e) || (/^(select|option)$/i).test(e.target.tagName)) return false;
if (tapIgnoreEvent(e) || isSelectOrOption(e.target.tagName)) return false;

if (!tapHasPointerMoved(e)) {
tapClick(e);
Expand Down Expand Up @@ -434,7 +434,7 @@ function tapTouchEnd(e) {
if (!tapHasPointerMoved(e)) {
tapClick(e);

if ((/^(select|option)$/i).test(e.target.tagName)) {
if (isSelectOrOption(e.target.tagName)) {
e.preventDefault();
}
}
Expand Down Expand Up @@ -593,6 +593,10 @@ function tapTargetElement(ele) {
return ele;
}

function isSelectOrOption(tagName){
return (/^(select|option)$/i).test(tagName);
}

ionic.DomUtil.ready(function() {
var ng = typeof angular !== 'undefined' ? angular : null;
//do nothing for e2e tests
Expand Down

0 comments on commit a017dfe

Please sign in to comment.