File tree Expand file tree Collapse file tree 4 files changed +15
-1
lines changed
Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,7 @@ export function toCamelCase(value: string | undefined): string {
1212export function isNumber ( value : string ) : boolean {
1313 return value . match ( numberRegex ) !== null ;
1414}
15+
16+ export function sanitizeSelector ( value : string ) : string {
17+ return value . replace ( / ( [ \n \r \t ] + ) / ig, ' ' ) ;
18+ }
Original file line number Diff line number Diff line change 11import * as postcss from 'postcss' ;
22import { DeclarationWalker } from './DeclarationWalker' ;
33import { Properties } from '../types' ;
4+ import { sanitizeSelector } from '../utils/strings' ;
45
56
67export class RuleWalker {
@@ -23,6 +24,6 @@ export class RuleWalker {
2324 } ) ;
2425
2526 // convert to string and add to file
26- this . _rules [ rule . selector ] = decWalker . getProperties ( ) ;
27+ this . _rules [ sanitizeSelector ( rule . selector ) ] = decWalker . getProperties ( ) ;
2728 }
2829}
Original file line number Diff line number Diff line change @@ -110,4 +110,5 @@ cssRule('@page', {
110110
111111 expect ( convertCss ( testCase ) ) . to . eventually . equal ( result ) . notify ( done ) ;
112112 } ) ;
113+
113114} ) ;
Original file line number Diff line number Diff line change 1+ import * as assert from 'assert' ;
2+ import { sanitizeSelector } from '../src/utils/strings' ;
3+
4+ describe ( 'strings' , ( ) => {
5+ it ( 'sanitizeSelector()' , ( ) => {
6+ assert . equal ( sanitizeSelector ( `.first \n\t \r.second` ) , '.first .second' ) ;
7+ } ) ;
8+ } ) ;
You can’t perform that action at this time.
0 commit comments