Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Work around safari touchevent listener bug #33

Closed
dfreedm opened this issue Aug 5, 2014 · 6 comments
Closed

Work around safari touchevent listener bug #33

dfreedm opened this issue Aug 5, 2014 · 6 comments
Assignees
Labels

Comments

@dfreedm
Copy link
Contributor

dfreedm commented Aug 5, 2014

If touchevent listeners are added to a node from another document, then that node is added to the main document, the touch event listeners will not fire in iOS Safari 7.

Reproduction:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Safari broken touches</title>
    <style>
      #target {
        width: 100px;
        height: 100px;
        background: orange;
      }
    </style>
  </head>
  <body>
    <div id="host"></div>

    <script>
      function log(e) {
        console.log(e.type);
      };

      var host = document.querySelector('#host');

      var template = document.implementation.createHTMLDocument();
      var target = template.createElement('div');
      target.id = 'target';

      // works
      //host.appendChild(target);

      target.addEventListener('touchstart', log);
      target.addEventListener('touchmove', log);
      target.addEventListener('touchend', log);

      // broken
      host.appendChild(target);
    </script>
  </body>
</html>
@dfreedm dfreedm self-assigned this Aug 5, 2014
@dfreedm
Copy link
Contributor Author

dfreedm commented Aug 5, 2014

@jmesserly
Copy link

the closest bug I could find was https://bugs.webkit.org/show_bug.cgi?id=105406, but i'm not sure it's related.

@dfreedm
Copy link
Contributor Author

dfreedm commented Aug 5, 2014

Horrible workarounds:

  1. document.body.addEventListener('touchstart', function(){}) will trigger the broken node's event handlers, but removeEventListener will turn them back off again.
  2. Use attachedCallback to remove and re-add touch listeners.

Both are pretty heinous, and would have to be triggered for iOS only.

@sorvell
Copy link
Contributor

sorvell commented Aug 5, 2014

Let's go with #1 (Safari only) and file a bug.

On Tue, Aug 5, 2014 at 12:18 PM, Daniel Freedman [email protected]
wrote:

Horrible workarounds:

  1. document.body.addEventListener('touchstart', function(){}) will
    trigger the broken node's event handlers, but removeEventListener will
    turn them back off again.
  2. Use attachedCallback to remove and re-add touch listeners.

Both are pretty heinous, and would have to be triggered for iOS only.


Reply to this email directly or view it on GitHub
#33 (comment)
.

dfreedm added a commit that referenced this issue Aug 5, 2014
@dfreedm
Copy link
Contributor Author

dfreedm commented Aug 5, 2014

Filed safari bug: https://bugs.webkit.org/show_bug.cgi?id=135628

@sorvell, Should I leave this open to track, or close with the workaround in place?

@sorvell
Copy link
Contributor

sorvell commented Aug 6, 2014

open, I think.

On Tue, Aug 5, 2014 at 4:46 PM, Daniel Freedman [email protected]
wrote:

Filed safari bug: https://bugs.webkit.org/show_bug.cgi?id=135628

@sorvell https://github.com/sorvell, Should I leave this open to track,
or close with the workaround in place?


Reply to this email directly or view it on GitHub
#33 (comment)
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants