googlearchive / polymer-gestures

84 stars 27 forks source link

Fix finding targets #48

Closed sbmaxx closed 10 years ago

sbmaxx commented 10 years ago

In mobile safari at least on each move action we trying to find touch-action property, but we have error here:

    findTouchAction: function(inEvent) {
      var n;
      if (HAS_FULL_PATH && inEvent.path) {
        var path = inEvent.path;
        for (var i = 0; i < path.length; i++) {
          n = path[i];
          if (n.nodeType === Node.ELEMENT_NODE && n.hasAttribute('touch-action')) {
            return n.getAttribute('touch-action');
          }
        }
      } else {
        n = inEvent.target;
        while(n) {
          if (n.hasAttribute('touch-action')) {
            return n.getAttribute('touch-action');
          }
          n = n.parentNode || n.host;
        }
      }
      // auto is default
      return "auto";
    },

Sometimes n doesn't have method hasAttribute. I did not search for the reason, but for workaround we can add

typeof n.hasAttribute === 'function'

in condition.

I will search for the real issue later.

dfreedm commented 10 years ago

I think I fixed this in 8945a0b4 with n.nodeType === Node.ELEMENT_NODE. All Element nodes must have hasAttribute