Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE EventTarget undefined - problem and workaround #31

Open
cambiata opened this issue Nov 6, 2015 · 1 comment
Open

IE EventTarget undefined - problem and workaround #31

cambiata opened this issue Nov 6, 2015 · 1 comment

Comments

@cambiata
Copy link

cambiata commented Nov 6, 2015

Hxdom doesn't work for me out of the box in Internet Explorer 11 (and probably not in earlier versions) - I get an "'EventTarget' is undefined" error, and that halts the whole thing as hxdom_VirtualNode.super = EventTarget.

My workaround is to mock the EventTarget by loading the js code below before the hxdom script.
Maybe there are other solutions to this, but I just wanted to share if someone else faces the same problem.

Thanks a lot for this awesome library, Sam!
/ Jonas

// eventtarget.js

if (EventTarget == undefined) {

    //alert('EventTarget is undefined');

    function EventTarget() {
      var eventTarget = document.createDocumentFragment();
      function delegate(method) {
        this[method] = eventTarget[method].bind(eventTarget);
      }
      [
        "addEventListener",
        "dispatchEvent",
        "removeEventListener"
      ].forEach(delegate, this);
    }
}

@hexonaut
Copy link
Owner

hexonaut commented Nov 6, 2015

Ah thanks for this. I should have that mentioned somewhere. I'll leave this task open to remind me. I had a problem with the span html element as well. I just include this code:

window.EventTarget || (window.EventTarget = function () {}); window.HTMLSpanElement || (window.HTMLSpanElement = function () {});

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

No branches or pull requests

2 participants