From 331b650564267e65922ab287f5d8eeaad9b8621d Mon Sep 17 00:00:00 2001 From: Rasmus Porsager Date: Tue, 14 Apr 2020 12:21:01 +0200 Subject: [PATCH] Remove bad single line comments support --- lib/create.js | 8 ++------ tests/index.js | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/create.js b/lib/create.js index 50bf39e..5be58f5 100644 --- a/lib/create.js +++ b/lib/create.js @@ -58,7 +58,7 @@ export default function bss({ function global() { const style = b.apply(b, arguments) - parse(removeComments(style.content).trim(), '__raw').forEach(x => + parse(style.content.trim(), '__raw').forEach(x => insert(x.replace(/\.__raw/g, '').trim()) ) } @@ -68,7 +68,7 @@ export default function bss({ return this.className this.className = b.prefix + ++b.count - const x = parse(removeComments(this.content).trim(), this.className) + const x = parse(this.content.trim(), this.className) x.forEach(insert) return x.name } @@ -114,10 +114,6 @@ export default function bss({ return x } - function removeComments(str) { - return str.replace(/\/\/.*?(\n|$)/g, '\n').replace(/\/\*[\s\S]*?\*\//g, '') - } - function insert(rule) { if (append) { style && doc.head && doc.head.appendChild(style) diff --git a/tests/index.js b/tests/index.js index d709a1c..8ba6c87 100644 --- a/tests/index.js +++ b/tests/index.js @@ -166,7 +166,8 @@ t('Multiline property values', () => { ] }) -t('Comments in strings', () => { +/* +t('Inline comments', () => { b`position: absolute; // This is absolute transform: translate(-50%, -50%) // This is multi line rotate(-45deg); // And here it ends`.toString() @@ -176,6 +177,7 @@ t('Comments in strings', () => { cn() + cn() + '{position:absolute;transform:translate(-50%, -50%) rotate(-45deg);}' ] }) +*/ t('@keyframes', () => { b`