mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-01 01:59:10 +00:00
[fix] StyleSheet SSR API
Without a getter, an outdated version of `sheet` is returned after `getStyleSheet` is called. This is exposed in the public API via `AppRegistry.getApplication`. Close #1874
This commit is contained in:
committed by
Nicolas Gallagher
parent
a660377050
commit
900e7e5c01
+21
@@ -1,9 +1,11 @@
|
||||
/* eslint-env jasmine, jest */
|
||||
|
||||
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
||||
import I18nManager from '../../I18nManager';
|
||||
import ReactNativePropRegistry from '../ReactNativePropRegistry';
|
||||
import createStyleResolver from '../createStyleResolver';
|
||||
|
||||
const canUseDOM = ExecutionEnvironment.canUseDOM;
|
||||
let styleResolver;
|
||||
|
||||
describe('StyleSheet/createStyleResolver', () => {
|
||||
@@ -74,5 +76,24 @@ describe('StyleSheet/createStyleResolver', () => {
|
||||
test('resolves inline-style pointerEvents to classname', () => {
|
||||
expect(styleResolver.resolve({ pointerEvents: 'box-none' })).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('sheet', () => {
|
||||
beforeEach(() => {
|
||||
ExecutionEnvironment.canUseDOM = false;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
ExecutionEnvironment.canUseDOM = canUseDOM;
|
||||
});
|
||||
|
||||
test('returns the new sheet once re-initialized', () => {
|
||||
const sheet = styleResolver.sheet;
|
||||
|
||||
// re-initialize the sheet
|
||||
styleResolver.getStyleSheet();
|
||||
|
||||
expect(styleResolver.sheet).not.toBe(sheet);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -237,7 +237,9 @@ export default function createStyleResolver() {
|
||||
return result;
|
||||
},
|
||||
resolve,
|
||||
sheet
|
||||
get sheet() {
|
||||
return sheet;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user