Skip to content

Commit 46cc532

Browse files
committed
Fix allow-compile-style.
1 parent b616975 commit 46cc532

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- fixed: NoSQL comparing dates `equal` in `where` condition
5353
- fixed: a problem with `booting` packages if are used custom paths (by @harry-stot)
5454
- fixed: JavaScript compression
55+
- fixed: `allow-compile-style` for inline CSS in views
5556

5657
- improved: events
5758
- improved: parsing data from requests

internal.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const REG_CSS_6 = /\,\s{1,}/g;
7070
const REG_CSS_7 = /\s\}/g;
7171
const REG_CSS_8 = /\s\{/g;
7272
const REG_CSS_9 = /\;\}/g;
73+
const REG_CSS_10 = /\$[a-z0-9-_]+\:.*?;/gi;
74+
const REG_CSS_11 = /\$[a-z0-9-_]+/gi;
7375
const AUTOVENDOR = ['filter', 'appearance', 'column-count', 'column-gap', 'column-rule', 'display', 'transform', 'transform-style', 'transform-origin', 'transition', 'user-select', 'animation', 'perspective', 'animation-name', 'animation-duration', 'animation-timing-function', 'animation-delay', 'animation-iteration-count', 'animation-direction', 'animation-play-state', 'opacity', 'background', 'background-image', 'font-smoothing', 'text-size-adjust', 'backface-visibility', 'box-sizing', 'overflow-scrolling'];
7476
const WRITESTREAM = { flags: 'w' };
7577
const EMPTYBUFFER = framework_utils.createBufferSize(0);
@@ -2360,6 +2362,9 @@ function compressJS(html, index, filename) {
23602362

23612363
function compressCSS(html, index, filename) {
23622364

2365+
if (!F.config['allow-compile-style'])
2366+
return html;
2367+
23632368
var strFrom = '<style type="text/css">';
23642369
var strTo = '</style>';
23652370

@@ -2389,7 +2394,7 @@ function variablesCSS(content) {
23892394

23902395
var variables = {};
23912396

2392-
content = content.replace(/\$[a-z0-9-_]+\:.*?;/gi, function(text) {
2397+
content = content.replace(REG_CSS_10, function(text) {
23932398
var index = text.indexOf(':');
23942399
if (index === -1)
23952400
return text;
@@ -2398,7 +2403,7 @@ function variablesCSS(content) {
23982403
return '';
23992404
});
24002405

2401-
content = content.replace(/\$[a-z0-9-_]+/gi, function(text) {
2406+
content = content.replace(REG_CSS_11, function(text) {
24022407
var variable = variables[text];
24032408
return variable ? variable : text;
24042409
}).trim();

0 commit comments

Comments
 (0)