From 0b4d12a71f343bf174fc8d4ec9613c4623d7b4b3 Mon Sep 17 00:00:00 2001 From: eight Date: Mon, 15 Oct 2018 15:26:47 +0800 Subject: [PATCH] Fix: styleCodeEmpty returns true for empty string --- edit/sections-editor.js | 1 - js/sections-util.js | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/edit/sections-editor.js b/edit/sections-editor.js index 27607d66..a06223d3 100644 --- a/edit/sections-editor.js +++ b/edit/sections-editor.js @@ -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(); diff --git a/js/sections-util.js b/js/sections-util.js index 71ffabbe..aeeeb19b 100644 --- a/js/sections-util.js +++ b/js/sections-util.js @@ -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) {