closest icon indicating copy to clipboard operation
closest copied to clipboard

3.0.0+ not working in IE 11

Open joebochill opened this issue 5 years ago • 7 comments

Version 3.0.0+ is not working with IE 11.

Object doesn't support property or method 'closest'

I'm using it as follows:

_action(evt) {
  if (!condition) { return; }
  else if (!evt.target.closest('.class')) {
    this._doSomething();
  }
}

logging evt.target.closest is undefined.

The error log also spits out: Object doesn't support property or method 'repeat', which is not coming from my code.

If I drop back down to version 2.0.2, everything works fine.

joebochill avatar Jul 22 '19 22:07 joebochill

Same issue here - 2.0.2 is working fine

markdavies avatar Jul 31 '19 00:07 markdavies

There is a breaking change between versions For Node usage, run closest with your window object: const elementClosest = require('element-closest'); elementClosest(window); // this is used to reference window.Element

IndProgo avatar Aug 29 '19 10:08 IndProgo

const elementClosest = require('element-closest'); elementClosest(window); // this is used to reference window.Element

While confusing, this actually does the job. I think the docu and description are quite confusing and one might think import 'element-closest' would do the trick. Sadly this isn't the case.

You need to initialize the plugin using elementClosest(window); in a node context (eg. webpack, gulp etc.)

diverent2 avatar Oct 21 '19 13:10 diverent2

It does work in browser/IE11 context, but for me it meant importing import 'element-closest/browser'.

wouterkroes avatar Oct 22 '19 09:10 wouterkroes

@wouterkroes would be great to have it in README.

seyfer avatar Jan 08 '20 14:01 seyfer

Yeah I agree! But I am not a owner/contributor of this repo. Maybe @jonathantneal could add it himself?

wouterkroes avatar Jan 08 '20 14:01 wouterkroes

Ups totally forgot to open the PR 🤦‍♂😅 Here we go :D https://github.com/jonathantneal/closest/pull/30

diverent2 avatar Jan 08 '20 14:01 diverent2