mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 22:51:06 +08:00
DEV: refactors textarea-selection helper to prevent leaking (#7709)
This commit is contained in:
@ -59,8 +59,6 @@
|
|||||||
"selectKitSelectRowByIndex": true,
|
"selectKitSelectRowByIndex": true,
|
||||||
"selectKitSelectRowByName": true,
|
"selectKitSelectRowByName": true,
|
||||||
"selectKitSelectRowByValue": true,
|
"selectKitSelectRowByValue": true,
|
||||||
"setTextareaSelection": true,
|
|
||||||
"getTextareaSelection": true,
|
|
||||||
"sinon": true,
|
"sinon": true,
|
||||||
"test": true,
|
"test": true,
|
||||||
"triggerEvent": true,
|
"triggerEvent": true,
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import componentTest from "helpers/component-test";
|
import componentTest from "helpers/component-test";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import formatTextWithSelection from "helpers/d-editor-helper";
|
import formatTextWithSelection from "helpers/d-editor-helper";
|
||||||
|
import {
|
||||||
|
setTextareaSelection,
|
||||||
|
getTextareaSelection
|
||||||
|
} from "helpers/textarea-selection-helper";
|
||||||
|
|
||||||
moduleForComponent("d-editor", { integration: true });
|
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 sinon/pkg/sinon
|
||||||
|
|
||||||
//= require helpers/assertions
|
//= require helpers/assertions
|
||||||
//= require helpers/textarea-selection
|
|
||||||
//= require helpers/select-kit-helper
|
//= require helpers/select-kit-helper
|
||||||
|
|
||||||
//= require helpers/qunit-helpers
|
//= require helpers/qunit-helpers
|
||||||
|
Reference in New Issue
Block a user