Skip to content

Commit

Permalink
fix(transform): IE11 doesn't support dotAll (styled-components#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
agriffis committed Apr 26, 2021
1 parent 09c543d commit cced079
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/transform.ts
Expand Up @@ -6,7 +6,8 @@ import { propGetters } from './propGetters'
const PROP_CHAR = `[-\\w]`

// prop value consists of non-semis and no curly braces unless backslash-escaped.
const VALUE_CHAR = `(?:\\\\.|[^\\\\;{}])`
// This uses [\s\S] instead of . because IE11 doesn't support the s flag.
const VALUE_CHAR = `(?:\\\\[\\s\\S]|[^\\\\;{}])`

// prettier-ignore
const PROP_PATT = (
Expand All @@ -29,7 +30,7 @@ const MEDIA_PATT = (
`(\\s*\\{)` // brace & whitespace
)

const MATCH_REGEXP = new RegExp(`(?:${PROP_PATT}|${MEDIA_PATT})`, `gs`)
const MATCH_REGEXP = new RegExp(`(?:${PROP_PATT}|${MEDIA_PATT})`, `g`)

export function transform(rawValue: any): any {
if (typeof rawValue !== 'string') return rawValue
Expand Down Expand Up @@ -68,7 +69,7 @@ const QUERY_REGEXP = new RegExp(
`(\\s*:\\s*)` + // colon & whitespace
`([^\\)]*?)` + // capture prop value (non-greedy)
`(\\s*\\))`, // close paren, whitespace
`gs`
`g`
)

function mediaTransform(rawValue: string) {
Expand Down

0 comments on commit cced079

Please sign in to comment.