alexgibson / tap.js

DEPRECATED - A custom 'tap' event JavaScript plugin for touch devices
Other
349 stars 65 forks source link

Fix for IE11 not supporting CustomEvent constructor #20

Closed bregenspan closed 9 years ago

bregenspan commented 9 years ago

This fixes an error in IE11, where window.CustomEvent is present, for whatever reason, but defined as an object (see http://msdn.microsoft.com/en-us/library/ie/ff974338%28v=vs.85%29.aspx).

alexgibson commented 9 years ago

Thanks for the PR!

So I believe the issue here is that Safari returns a type object for CustomEvent, so this change will cause a regression in that browser. I wonder if we should specifically check for IE in this instance (unless you have another suggestion). Feels dirty, but given the differences this might be unavoidable?

Looks like IE > 11 has the CustomEvent constructor from what I can tell.

bregenspan commented 9 years ago

Oy! Browsers.

Yeah I can't think of a super-clean way -- try/catch around new CustomEvent() would also be ugly. I checked Modernizr's solution and it matches this one, so I'm wondering if there's any drawback to having Safari still use the old API for now. The syntax is uglier, but since it already has to be included here, there might be no issues with Safari using it.

Forward-compatibility could be a concern, but I can't find any plans to drop the old API any time soon.

alexgibson commented 9 years ago

I see Polymer resorts to UA detection for this: https://github.com/webcomponents/webcomponentsjs/blob/master/src/CustomElements/boot.js#L92

In the interest of letting capable browsers use the new constructor type, I'd consider a dirty check for IE<=11. Sometimes you got to do what's best despite feeling bad for it?

bregenspan commented 9 years ago

(Closing this out for now due to the Safari issue.)