Skip to content

Commit

Permalink
@media queries comma splits selectors bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Jun 22, 2023
1 parent 7c4d878 commit 725b2b4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/bundle.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs"
},
"version": "2.10.5",
"version": "2.10.6",
"ava": {
"files": [
"./test/specs/*.js"
Expand Down
6 changes: 3 additions & 3 deletions src/compression/fela-compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ margin margin-top margin-left margin-bottom margin-right justify-content
border width height left border-radius background bottom position align-items
center bottom absolute relative float right opacity z-index min-width
min-height border-top border-bottom border-left border-right filter
font-weight font-size none hidden auto display block inline inline-block
font-family font-size font-weight none hidden auto display block inline inline-block
padding padding-top padding-bottom padding-left padding-right text-align
flex-direction column box-shadow rotate content text-decoration
fixed color space-between overflow-x overflow-y
flex-direction column box-shadow rotate content text-decoration max-width
fixed color space-between overflow-x overflow-y background-size
`.replace(/\s+/g, ',').split(/[, ]/g).filter(Boolean)

const prepareCompressRule = () => {let i=0; return () => `a${zipnum(i++)}`}
Expand Down
11 changes: 7 additions & 4 deletions src/fns/analyseLine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { camelify, re, unescape } from '../utils'
import { when, compose, fromPairs, map, reverse, toPairs } from 'pepka'
import { when, compose, fromPairs, map, reverse, toPairs, complement, replace, split, test, ifElse } from 'pepka'
import { Levels } from '../classes/Levels'
import { getDics } from '../compression/fela-compress'

Expand All @@ -12,6 +12,7 @@ export const analyseLine = (() => {
const selectorRE = re.selector
const spreadRE = re.spread
const delimRE = re.delim
const mediaRE = re.media
const trailingColonRE = re.trailing_colon
const decompress = when(() => compression, (s) => dics.dicRev[s] || s)
const getValue = (value: string) => {
Expand Down Expand Up @@ -43,9 +44,11 @@ export const analyseLine = (() => {
break
case (groups = selectorRE.exec(line)) !== null:
names.splice(0)
names.push(...line.split(delimRE).map((selector) =>
selector.replace(trailingColonRE, '$1')
))
names.push(...compose(
map(replace(trailingColonRE, '$1')),
ifElse(test(mediaRE), (l: string) => [l], split(delimRE))
)(line)
)
break
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/fns/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { splitNonEscaped, escape, re } from '../utils'
import {
compose, replace, forEach, type, map, trim,
complement, isEmpty, filter, always, not, when
complement, isEmpty, filter, always, not, when, explore
} from 'pepka'
import { Levels } from '../classes/Levels'
import { analyseLine } from './analyseLine'
Expand All @@ -27,11 +27,10 @@ export const parse = (() => {
}
}),
createFunctions(aug),
// when(always(not(aug)), createFunctions),
filter(complement(isEmpty) as any),
map(trim),
splitNonEscaped(delimiters),
replace(/(\{|\})/g, (_, brace, offset, full) => {
replace(/(\{|\})/g, (_: any, brace: string, offset: number, full: string[]) => {
if(!isDelimiter(full[offset-1])) brace = ';' + brace
if(!isDelimiter(full[offset+1])) brace += ';'
return brace
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const re = {
rule_free: /(^|\r|\n|;|{)\s*([a-z-]+)[ :][\t ]*?:?[\t ]*?([^;\r\n]+)/g,
selector: /^(([\|~\$@>\*\.:&\(\)\^="\-\[\]]+).*[ ,]*)+:?$/,
spread: /^\.\.\.(\S*)$/,
media: /^@media /,
delim: /\s*,\s*/g,
trailing_colon: /(.*):$/,
class_mod: /[.&]/
Expand Down

0 comments on commit 725b2b4

Please sign in to comment.