Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Commit

Permalink
[Prefix] Add an option to prefix for all user agent
Browse files Browse the repository at this point in the history
My use case for this, is to prefix for all user agent on the server side
and only for the browser agent on the client side. As pointed out here facebook/react#1979
I think that it's a very good trade-off.
This allow me to remove the user agent from the memoization I use on the `renderToString` method.

The test fails because of robinweser/inline-style-prefixer#58.
I'm gonna address it.

Fix #546.
  • Loading branch information
oliviertassinari authored and ianobermiller committed Jan 27, 2016
1 parent 99b4508 commit d0b3289
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/__tests__/style-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ describe('<Style> component', () => {
`);
});

it('add all the prefixes when we ask for', () => {
const output = TestUtils.renderIntoDocument(
<Style
radiumConfig={{userAgent: 'all'}}
rules={{div: {transform: 'rotate(90)'}}}
/>
);

const style = getElement(output, 'style');
expectCSS(style, `
div{
transform:rotate(90);
-webkit-transform:rotate(90);
-moz-transform:rotate(90);
-ms-transform:rotate(90);
}
`);
});

it('adds scopeSelector to each selector', () => {
const output = TestUtils.renderIntoDocument(
<Style
Expand Down
9 changes: 8 additions & 1 deletion src/prefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ function getPrefixer(userAgent: ?string): InlineStylePrefixer {
}

if (!_cachedPrefixer || actualUserAgent !== _lastUserAgent) {
_cachedPrefixer = new InlineStylePrefixer({userAgent: actualUserAgent});
if (actualUserAgent === 'all') {
_cachedPrefixer = {
prefix: InlineStylePrefixer.prefixAll,
prefixedKeyframes: 'keyframes'
};
} else {
_cachedPrefixer = new InlineStylePrefixer({userAgent: actualUserAgent});
}
_lastUserAgent = actualUserAgent;
}
return _cachedPrefixer;
Expand Down

0 comments on commit d0b3289

Please sign in to comment.