ClojureScript

Protocols not working in IE8

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    IE8
  • Patch:
    Code

Description

The function generated by defprotocol does not work in IE8. I haven't tried any other versions of IE. The fix is pretty simple, however I don't know the edge cases so consider the patch of a proof of concept.

I'll use IEquiv as an example. The currently generated code is:

cljs.core._equiv = function(a, b) {
return cljs.core.truth_(cljs.core.truth_(a) ? a.cljs$core$IEquiv$_equiv : a) ? a.cljs$core$IEquiv$_equiv(a, b) : function() {
var b = _equiv[goog.typeOf.call(null, a)];
if(cljs.core.truth_(b)) { return b }else {
if(b = equiv., cljs.core.truth_(b)) { return b }else { throw cljs.core.missing_protocol.call(null, "IEquiv.-equiv", a); }
}
}().call(null, a, b)
};

Inside the function the reference to _equiv is unqualified. In IE8, this evaluates to undefined. Using the fully qualified name fixes the issue. So, _equiv[goog.typeOf.call(null, a)] becomes cljs.core._equiv[goog.typeOf.call(null, a)], and equiv. becomes cljs.core.equiv.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: