mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Don't load JS via SCRIPT tag in QUnit mode
This commit is contained in:
parent
e22d88c91d
commit
e66fa82f3a
3 changed files with 20 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
import loadScript from 'discourse/lib/load-script';
|
||||
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
const LOAD_ASYNC = !Ember.Test;
|
||||
|
||||
export default Ember.Component.extend({
|
||||
mode: 'css',
|
||||
classNames: ['ace-wrapper'],
|
||||
|
@ -23,7 +25,7 @@ export default Ember.Component.extend({
|
|||
|
||||
@observes('mode')
|
||||
modeChanged() {
|
||||
if (this._editor && !this._skipContentChangeEvent) {
|
||||
if (LOAD_ASYNC && this._editor && !this._skipContentChangeEvent) {
|
||||
this._editor.getSession().setMode("ace/mode/" + this.get('mode'));
|
||||
}
|
||||
},
|
||||
|
@ -56,10 +58,14 @@ export default Ember.Component.extend({
|
|||
if (!this.element || this.isDestroying || this.isDestroyed) { return; }
|
||||
const editor = loadedAce.edit(this.$('.ace')[0]);
|
||||
|
||||
editor.setTheme("ace/theme/chrome");
|
||||
if (LOAD_ASYNC) {
|
||||
editor.setTheme("ace/theme/chrome");
|
||||
}
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.setOptions({fontSize: "14px"});
|
||||
editor.getSession().setMode("ace/mode/" + this.get('mode'));
|
||||
if (LOAD_ASYNC) {
|
||||
editor.getSession().setMode("ace/mode/" + this.get('mode'));
|
||||
}
|
||||
editor.on('change', () => {
|
||||
this._skipContentChangeEvent = true;
|
||||
this.set('content', editor.getSession().getValue());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue