deshiknaves / caret-pos

Locate the current position of the caret. A plain JavaScript version of Caret.js.
MIT License
120 stars 15 forks source link

element.contentEditable is undefined in some DOM's #11

Closed nivzelber closed 4 years ago

nivzelber commented 4 years ago

In here you're accessing the attribute contentEditable directly via the element. https://github.com/deshiknaves/caret-pos/blob/94657c8aac4b8c40002029c4c5b31584e46e8849/src/utils.js#L8-L11 This is allowed in browsers like Chrome or FireFox, however - in other DOM environments like IE or JSDOM (the popular library used in jest testing), the only way to access this attribute is via element.getAttribute("contenteditable"). This is also supported by any other browsers and DOM environments, and should be changed to support more projects :smile: I've opened a PR that fixes it.

10

deshiknaves commented 4 years ago

13 fixes this issue