From 83bfa78c1b6f65e0cfd88d75e0c3a4a0a1a222b6 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 27 Apr 2019 16:27:03 +0300 Subject: [PATCH] 2.6.0-beta.7 - block comments. --- dist/bundle.esm.js | 2 +- dist/bundle.js | 2 +- package-lock.json | 2 +- package.json | 2 +- src/css-lit.ts | 5 +++-- test/specs/lit.ts | 4 +++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dist/bundle.esm.js b/dist/bundle.esm.js index e8e0ae2..c735b9b 100644 --- a/dist/bundle.esm.js +++ b/dist/bundle.esm.js @@ -1 +1 @@ -import{createRenderer as e,combineRules as t}from"fela";import{renderToMarkup as r,rehydrate as n,render as o}from"fela-dom";import i from"fela-plugin-embedded";import u from"fela-plugin-prefixer";import c from"fela-plugin-fallback-value";import f from"fela-plugin-unit";var p=function(){return(p=Object.assign||function(e){for(var t,r=1,n=arguments.length;r\*\.:&\(\)\^="\-\[\]]+).*[ ,]*)+:?$/,l=/\s*,\s*/g,h=/(.*):$/,function(e,t,r){var n;switch(!0){case"{"==t:e.add(r);break;case"}"==t:e.pop();break;case null!=(n=a.exec(t)):e.merge(y(n[1]),isNaN(n[3])?n[3]:+n[3]);break;case null!=(n=s.exec(t)):r.splice(0),r.push.apply(r,t.split(l).map(function(t){return"."==(t=t.replace(h,"$1"))[0]&&(t=e.depth>1?"& "+t:t.slice(1)),t}))}}),w=function(){var e=["\n","\r",";"],t=function(t){return e.includes(t)},r=new RegExp("["+e.join("")+"]","g"),n=/^\/\/.*$/;return function(e){for(var o=[],i=1;i\*\.:&\(\)\^="\-\[\]]+).*[ ,]*)+:?$/,l=/\s*,\s*/g,h=/(.*):$/,function(e,t,r){var n;switch(!0){case"{"==t:e.add(r);break;case"}"==t:e.pop();break;case null!=(n=a.exec(t)):e.merge(y(n[1]),isNaN(n[3])?n[3]:+n[3]);break;case null!=(n=s.exec(t)):r.splice(0),r.push.apply(r,t.split(l).map(function(t){return"."==(t=t.replace(h,"$1"))[0]&&(t=e.depth>1?"& "+t:t.slice(1)),t}))}}),w=function(){var e=["\n","\r",";"],t=function(t){return e.includes(t)},r=new RegExp("["+e.join("")+"]","g"),n=/((^\s*?\/\/.*$)|\/\*(.|[\n\r])*?\*\/)/gm;return function(e){for(var o=[],i=1;i\*\.:&\(\)\^="\-\[\]]+).*[ ,]*)+:?$/,r=/\s*,\s*/g,n=/(.*):$/;return function(i,u,o){var a;switch(!0){case"{"==u:i.add(o);break;case"}"==u:i.pop();break;case null!=(a=e.exec(u)):i.merge(camelify(a[1]),isNaN(a[3])?a[3]:+a[3]);break;case null!=(a=t.exec(u)):o.splice(0),o.push.apply(o,u.split(r).map(function(e){return"."==(e=e.replace(n,"$1"))[0]&&(e=i.depth>1?"& "+e:e.slice(1)),e}))}}}(),css=function(){var e=["\n","\r",";"],t=function(t){return e.includes(t)},r=new RegExp("["+e.join("")+"]","g"),n=/^\/\/.*$/;return function(e){for(var i=[],u=1;u\*\.:&\(\)\^="\-\[\]]+).*[ ,]*)+:?$/,r=/\s*,\s*/g,n=/(.*):$/;return function(i,u,o){var a;switch(!0){case"{"==u:i.add(o);break;case"}"==u:i.pop();break;case null!=(a=e.exec(u)):i.merge(camelify(a[1]),isNaN(a[3])?a[3]:+a[3]);break;case null!=(a=t.exec(u)):o.splice(0),o.push.apply(o,u.split(r).map(function(e){return"."==(e=e.replace(n,"$1"))[0]&&(e=i.depth>1?"& "+e:e.slice(1)),e}))}}}(),css=function(){var e=["\n","\r",";"],t=function(t){return e.includes(t)},r=new RegExp("["+e.join("")+"]","g"),n=/((^\s*?\/\/.*$)|\/\*(.|[\n\r])*?\*\/)/gm;return function(e){for(var i=[],u=1;u { const delimiters = ['\n', '\r', ';'] const isDelimiter = (s: string) => delimiters.includes(s) const delimRE = new RegExp(`[${delimiters.join('')}]`, 'g') - const commentRE = /^\/\/.*$/ + const commentRE = /((^\s*?\/\/.*$)|\/\*(.|[\n\r])*?\*\/)/gm return (strings: string[], ...values: any[]) => { const names: string[] = [] // selector names, class names. const levels = new Levels() join(strings, values) + .replace(commentRE, '') .replace(/(\{|\})/g, (_, brace, offset, full) => { if(!isDelimiter(full[offset-1])) { brace = ';' + brace @@ -98,7 +99,7 @@ export const css = (() => { }) .split(delimRE) .forEach((line) => { - line = line.trim().replace(commentRE, '') + line = line.trim() if(line) { analyseLine(levels, line, names) } diff --git a/test/specs/lit.ts b/test/specs/lit.ts index 5efcdba..9a3e7a4 100644 --- a/test/specs/lit.ts +++ b/test/specs/lit.ts @@ -45,7 +45,9 @@ test('lit-css', (t) => { margin: some-shit; padding some-shit; those: shiii margin-left: ${value} - margin-right: 10px + margin-right: 10px /* + some block comment + */ >*:first-of-type { shit 66 .inner {