Fix: styleCodeEmpty returns true for empty string

This commit is contained in:
eight 2018-10-15 15:26:47 +08:00
parent 89f836c003
commit 0b4d12a71f
2 changed files with 3 additions and 1 deletions

View File

@ -118,7 +118,6 @@ function createSectionsEditor(style) {
nearbyElement instanceof Node &&
(nearbyElement.closest('#sections > .section') || {}).CodeMirror ||
getLastActivatedEditor();
console.log(cm);
if (nearbyElement instanceof Node && cm) {
const {left, top} = nearbyElement.getBoundingClientRect();
const bounds = cm.display.wrapper.getBoundingClientRect();

View File

@ -2,6 +2,9 @@
'use strict';
function styleCodeEmpty(code) {
if (!code) {
return true;
}
const rx = /\s+|\/\*[\s\S]*?\*\/|@namespace[^;]+;|@charset[^;]+;/giy;
while (rx.exec(code)) {
if (rx.lastIndex === code.length) {