A platform for community discussion. Free, open, simple.
DEV: refactors textarea-selection helper to prevent leaking (#7709)
Joffrey JAFFEUXde013262a769
diff --git a/.eslintrc b/.eslintrcindex 75fcbf094f5..e5a36abd281 100644--- a/.eslintrc+++ b/.eslintrc@@ -59,8 +59,6 @@"selectKitSelectRowByIndex": true,"selectKitSelectRowByName": true,"selectKitSelectRowByValue": true,- "setTextareaSelection": true,- "getTextareaSelection": true,"sinon": true,"test": true,"triggerEvent": true,diff --git a/test/javascripts/components/d-editor-test.js.es6 b/test/javascripts/components/d-editor-test.js.es6index edb1a53d6da..3ab5538a670 100644--- a/test/javascripts/components/d-editor-test.js.es6+++ b/test/javascripts/components/d-editor-test.js.es6@@ -1,6 +1,10 @@import componentTest from "helpers/component-test";import { withPluginApi } from "discourse/lib/plugin-api";import formatTextWithSelection from "helpers/d-editor-helper";+import {+ setTextareaSelection,+ getTextareaSelection+} from "helpers/textarea-selection-helper";moduleForComponent("d-editor", { integration: true });diff --git a/test/javascripts/helpers/textarea-selection-helper.js.es6 b/test/javascripts/helpers/textarea-selection-helper.js.es6new file mode 100644index 00000000000..1f914d794e0--- /dev/null+++ b/test/javascripts/helpers/textarea-selection-helper.js.es6@@ -0,0 +1,10 @@+export function setTextareaSelection(textarea, selectionStart, selectionEnd) {+ textarea.selectionStart = selectionStart;+ textarea.selectionEnd = selectionEnd;+}++export function getTextareaSelection(textarea) {+ const start = textarea.selectionStart;+ const end = textarea.selectionEnd;+ return [start, end - start];+}diff --git a/test/javascripts/helpers/textarea-selection.js b/test/javascripts/helpers/textarea-selection.jsdeleted file mode 100644index c406928dfcf..00000000000--- a/test/javascripts/helpers/textarea-selection.js+++ /dev/null@@ -1,15 +0,0 @@-Ember.Test.registerHelper("setTextareaSelection", function(- app,- textarea,- selectionStart,- selectionEnd-) {- textarea.selectionStart = selectionStart;- textarea.selectionEnd = selectionEnd;-});--Ember.Test.registerHelper("getTextareaSelection", function(app, textarea) {- var start = textarea.selectionStart;- var end = textarea.selectionEnd;- return [start, end - start];-});diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.jsindex 1fe03be5216..1d8a8aa42eb 100644--- a/test/javascripts/test_helper.js+++ b/test/javascripts/test_helper.js@@ -30,7 +30,6 @@//= require sinon/pkg/sinon//= require helpers/assertions-//= require helpers/textarea-selection//= require helpers/select-kit-helper//= require helpers/qunit-helpers