Skip to content

Commit cb0b271

Browse files
committed
perf(css-vars): remove empty selector regex
1 parent fcc9604 commit cb0b271

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/client/polyfills/css-shim/regex.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export const VAR_ASSIGN_START = /\B--[\w-]+\s*:/;
44

55
export const COMMENTS = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim;
66
export const TRAILING_LINES = /^[\t ]+\n/gm;
7-
export const EMPTY_SELECTORS = /[^{}]*{\s*}/gm;

src/client/polyfills/css-shim/template.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { findRegex } from './utils';
22
import { CSSTemplate, CSSVariables } from './interfaces';
3-
import { COMMENTS, EMPTY_SELECTORS, TRAILING_LINES, VAR_ASSIGN_START, VAR_USAGE_START } from './regex';
3+
import { COMMENTS, TRAILING_LINES, VAR_ASSIGN_START, VAR_USAGE_START } from './regex';
44

55

66
export function resolveVar(props: CSSVariables, prop: string, fallback: CSSTemplate | undefined): string {
@@ -128,7 +128,6 @@ export function compileTemplate(cssText: string): CSSTemplate {
128128
cssText = cssText.replace(COMMENTS, '');
129129

130130
cssText = removeCustomAssigns(cssText)
131-
.replace(EMPTY_SELECTORS, '')
132131
.replace(TRAILING_LINES, '');
133132

134133
const segments: CSSTemplate = [];

src/client/polyfills/css-shim/test/css-shim.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ describe('css-shim', () => {
231231

232232
expect(css(styleElm.innerHTML)).toBe(
233233
css(`
234+
html{}
234235
p {
235236
color: red;
236237
}
@@ -276,6 +277,7 @@ describe('css-shim', () => {
276277

277278
expect(css(styleElm.innerHTML)).toBe(
278279
css(`
280+
html{}
279281
.transform {
280282
transform: translate3d(0, 88px, 0);
281283
}
@@ -301,6 +303,7 @@ describe('css-shim', () => {
301303

302304
expect(css(styleElm.innerHTML)).toBe(
303305
css(`
306+
html{}
304307
@keyframes animation {
305308
0% { opacity: 0.3; }
306309
100% { opacity: 0.8; }
@@ -327,6 +330,7 @@ describe('css-shim', () => {
327330

328331
expect(css(styleElm.innerHTML)).toBe(
329332
css(`
333+
html{}
330334
@media only screen {
331335
body {
332336
color: red;
@@ -358,6 +362,7 @@ describe('css-shim', () => {
358362

359363
expect(css(styleElm.innerHTML)).toBe(
360364
css(`
365+
html{}
361366
div {
362367
animation-name: slidein;
363368
animation-duration: 3s;

0 commit comments

Comments
 (0)