Skip to content

Commit

Permalink
Add: isCodeEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Oct 6, 2018
1 parent 450cd60 commit 1cf6008
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions background/style-manager.js
@@ -1,7 +1,7 @@
/* eslint no-eq-null: 0, eqeqeq: [2, "smart"] */
/*
global createCache db calcStyleDigest normalizeStyleSections db promisify
getStyleWithNoCode msg styleCodeEmpty
getStyleWithNoCode msg
*/
'use strict';

Expand Down Expand Up @@ -304,7 +304,17 @@ const styleManager = (() => {
code += section.code;
}
}
return styleCodeEmpty(code) ? null : code;
return isCodeEmpty(code) ? null : code;
}

function isCodeEmpty(code) {
const rx = /\s+|\/\*[\s\S]*?\*\/|@namespace[^;]+;|@charset[^;]+;/giy;
while (rx.exec(code)) {
if (rx.lastIndex === code.length) {
return true;
}
}
return false;
}

function prepare() {
Expand Down

0 comments on commit 1cf6008

Please sign in to comment.