Skip to content

Attach events on IE8 #5

@tracend

Description

@tracend

Consider having backwards support for attaching events. For example:

// Vanilla
function attachEvent(element, type, handler) {
    if (element.addEventListener) {
        element.addEventListener(type, handler, false);
    }else if (element.attachEvent) {
        element.attachEvent('on' + type, handler);
    } else {
        element['on' + type] = handler;
    }
}

[].forEach.call(document.querySelectorAll('a'), function(el) {
  attachEvent(el, 'click', function() {
    // code…
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions