fixup efc001c0: css_beautify is dodgy
This commit is contained in:
parent
73dc33d376
commit
e65e3c9c0b
16
edit/edit.js
16
edit/edit.js
|
@ -1,6 +1,7 @@
|
|||
/* eslint brace-style: 0, operator-linebreak: 0 */
|
||||
/* global CodeMirror parserlib */
|
||||
/* global exports onDOMscripted */
|
||||
/* global onDOMscripted */
|
||||
/* global css_beautify */
|
||||
/* global CSSLint initLint linterConfig updateLintReport renderLintReport updateLinter */
|
||||
'use strict';
|
||||
|
||||
|
@ -1080,9 +1081,14 @@ function getEditorInSight(nearbyElement) {
|
|||
}
|
||||
|
||||
function beautify(event) {
|
||||
const script = $('script[src*="beautify-css-mod"]') ?
|
||||
[] : ['vendor-overwrites/beautify/beautify-css-mod.js'];
|
||||
onDOMscripted(script).then(doBeautify);
|
||||
onDOMscripted([
|
||||
'vendor-overwrites/beautify/beautify-css-mod.js',
|
||||
() => {
|
||||
if (!window.css_beautify && window.exports) {
|
||||
window.css_beautify = window.exports.css_beautify;
|
||||
}
|
||||
},
|
||||
]).then(doBeautify);
|
||||
|
||||
function doBeautify() {
|
||||
const tabs = prefs.get('editor.indentWithTabs');
|
||||
|
@ -1127,7 +1133,7 @@ function beautify(event) {
|
|||
[].concat.apply([], cm.doc.sel.ranges.map(r =>
|
||||
[Object.assign({}, r.anchor), Object.assign({}, r.head)]));
|
||||
const text = cm.getValue();
|
||||
const newText = exports.css_beautify(text, options);
|
||||
const newText = css_beautify(text, options);
|
||||
if (newText !== text) {
|
||||
if (!cm.beautifyChange || !cm.beautifyChange[cm.changeGeneration()]) {
|
||||
// clear the list if last change wasn't a css-beautify
|
||||
|
|
|
@ -122,6 +122,14 @@ function injectScript(properties) {
|
|||
if (!properties || !properties.src) {
|
||||
return;
|
||||
}
|
||||
if (injectScript.cache) {
|
||||
if (injectScript.cache.has(properties.src)) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
} else {
|
||||
injectScript.cache = new Set();
|
||||
}
|
||||
injectScript.cache.add(properties.src);
|
||||
const script = document.head.appendChild(document.createElement('script'));
|
||||
Object.assign(script, properties);
|
||||
if (!properties.onload) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user