DEV: refactors textarea-selection helper to prevent leaking (#7709)

This commit is contained in:
Joffrey JAFFEUX 2019-06-05 19:20:46 +02:00 committed by GitHub
parent 35d0fd038e
commit de013262a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 18 deletions

View File

@ -59,8 +59,6 @@
"selectKitSelectRowByIndex": true,
"selectKitSelectRowByName": true,
"selectKitSelectRowByValue": true,
"setTextareaSelection": true,
"getTextareaSelection": true,
"sinon": true,
"test": true,
"triggerEvent": true,

View File

@ -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 });

View File

@ -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];
}

View File

@ -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];
});

View File

@ -30,7 +30,6 @@
//= require sinon/pkg/sinon
//= require helpers/assertions
//= require helpers/textarea-selection
//= require helpers/select-kit-helper
//= require helpers/qunit-helpers