Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create-emotion-styled proxy with react-hot-loader and add appearance: none to search input #540

Merged
merged 3 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions packages/create-emotion-styled/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,21 @@ function createEmotionStyled(emotion: Emotion, view: ReactType) {
if (process.env.NODE_ENV !== 'production' && typeof Proxy !== 'undefined') {
createStyled = new Proxy(createStyled, {
get(target, property) {
throw new Error(
`You're trying to use the styled shorthand without babel-plugin-emotion.` +
`\nPlease install and setup babel-plugin-emotion or use the function call syntax(\`styled('${property}')\` instead of \`styled.${property}\`)`
)
switch (property) {
// react-hot-loader tries to access this stuff
case '__proto__':
case 'name':
case 'prototype':
case 'displayName': {
return target[property]
}
default: {
throw new Error(
`You're trying to use the styled shorthand without babel-plugin-emotion.` +
`\nPlease install and setup babel-plugin-emotion or use the function call syntax(\`styled('${property}')\` instead of \`styled.${property}\`)`
)
}
}
}
})
}
Expand Down
11 changes: 11 additions & 0 deletions packages/emotion/test/no-babel/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,15 @@ describe('css', () => {
styled.div``
}).toThrowErrorMatchingSnapshot()
})
test('styled does not throw an error when certain properties are accessed', () => {
expect(() => {
/* eslint-disable no-unused-expressions */
// eslint-disable-next-line no-proto
styled.__proto__
styled.prototype
styled.name
styled.displayName
/* eslint-enable no-unused-expressions */
}).not.toThrow()
})
})
1 change: 1 addition & 0 deletions packages/site/src/components/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Search extends React.Component<Props, State> {
outline: 0,
width: 16,
margin: 8,
appearance: 'none',
transition:
'width 200ms ease,padding 200ms ease, background-color 100ms ease',
'@media (max-width: 600px)': {
Expand Down