atom / line-ending-selector

Switch between Unix and Window style line endings.
MIT License
33 stars 18 forks source link

Use target.closest('atom-text-editor') to access the editor element #35

Closed as-cii closed 7 years ago

as-cii commented 7 years ago

Refs: https://github.com/atom/atom/issues/13189

With the removal of the shadow DOM boundary from atom-text-editor elements, event.target could sometimes report the hidden input inside the editor instead of the element itself. This caused the line-ending-selector:convert-to-CRLF and line-ending-selector:convert-to-LF commands to stop working because they were relying on event.target being an instance of TextEditorElement.

This pull request fixes it by using event.target.closest('atom-text-editor') instead, and by making tests more realistic to ensure that similar regressions can be caught in the future.

/cc: @atom/core