Skip to content

Commit

Permalink
Fix styles getting injected in the classname (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
pimmey authored and emmatown committed Dec 21, 2017
1 parent d140fb4 commit 2f774e6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/emotion/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function isLastCharDot(string) {
let hash
let name

const labelPattern = /label:\s*([^\s;\n]+)\s*[;\n]/g
const labelPattern = /label:\s*([^\s;\n{]+)\s*;/g

function createStyles(strings, ...interpolations) {
let stringMode = true
Expand Down
17 changes: 17 additions & 0 deletions packages/emotion/test/__snapshots__/label-pattern.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`label pattern input + label styled 1`] = `
.glamor-0 + label::after {
color: pink;
background: orange;
}
<div>
<input
className="glamor-0 glamor-1"
/>
<label>
Label
</label>
</div>
`;
28 changes: 28 additions & 0 deletions packages/emotion/test/label-pattern.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import styled from 'react-emotion'
import renderer from 'react-test-renderer'
import { flush } from 'emotion'

describe('label pattern', () => {
afterEach(() => flush())

test('input + label styled', () => {
const Input = styled.input`
& + label::after {
color: pink;
background: orange;
}
`

const tree = renderer
.create(
<div>
<Input />
<label>Label</label>
</div>
)
.toJSON()

expect(tree).toMatchSnapshot()
})
})

0 comments on commit 2f774e6

Please sign in to comment.