mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:13:38 +08:00
DEV: refactors textarea-selection helper to prevent leaking (#7709)
This commit is contained in:
parent
35d0fd038e
commit
de013262a7
|
@ -59,8 +59,6 @@
|
|||
"selectKitSelectRowByIndex": true,
|
||||
"selectKitSelectRowByName": true,
|
||||
"selectKitSelectRowByValue": true,
|
||||
"setTextareaSelection": true,
|
||||
"getTextareaSelection": true,
|
||||
"sinon": true,
|
||||
"test": true,
|
||||
"triggerEvent": true,
|
||||
|
|
|
@ -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 });
|
||||
|
||||
|
|
10
test/javascripts/helpers/textarea-selection-helper.js.es6
Normal file
10
test/javascripts/helpers/textarea-selection-helper.js.es6
Normal 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];
|
||||
}
|
|
@ -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];
|
||||
});
|
|
@ -30,7 +30,6 @@
|
|||
//= require sinon/pkg/sinon
|
||||
|
||||
//= require helpers/assertions
|
||||
//= require helpers/textarea-selection
|
||||
//= require helpers/select-kit-helper
|
||||
|
||||
//= require helpers/qunit-helpers
|
||||
|
|
Loading…
Reference in New Issue
Block a user