Revert SSR Image change

Reverts 3c660e2ad7

See #543
This commit is contained in:
Nicolas Gallagher
2017-09-19 15:20:26 -07:00
parent a5b1dda62d
commit d762d64b49
2 changed files with 2 additions and 14 deletions
+1 -12
View File
@@ -1,12 +1,10 @@
/* eslint-env jasmine, jest */ /* eslint-env jasmine, jest */
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
import Image from '../'; import Image from '../';
import ImageUriCache from '../ImageUriCache'; import ImageUriCache from '../ImageUriCache';
import React from 'react'; import React from 'react';
import { mount, render, shallow } from 'enzyme'; import { mount, shallow } from 'enzyme';
const originalCanUseDOM = ExecutionEnvironment.canUseDOM;
const originalImage = window.Image; const originalImage = window.Image;
describe('components/Image', () => { describe('components/Image', () => {
@@ -137,15 +135,6 @@ describe('components/Image', () => {
.attr('src') .attr('src')
).toBe(uriTwo); ).toBe(uriTwo);
}); });
test('is set immediately when rendered on the server', () => {
ExecutionEnvironment.canUseDOM = false;
const uri = 'https://google.com/favicon.ico';
const component = render(<Image source={{ uri }} />);
expect(component.find('img').attr('src')).toBe(uri);
expect(ImageUriCache.has(uri)).toBe(true);
ExecutionEnvironment.canUseDOM = originalCanUseDOM;
});
}); });
describe('prop "style"', () => { describe('prop "style"', () => {
+1 -2
View File
@@ -11,7 +11,6 @@
*/ */
import applyNativeMethods from '../../modules/applyNativeMethods'; import applyNativeMethods from '../../modules/applyNativeMethods';
import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
import createElement from '../../modules/createElement'; import createElement from '../../modules/createElement';
import { getAssetByID } from '../../modules/AssetRegistry'; import { getAssetByID } from '../../modules/AssetRegistry';
import ImageLoader from '../../modules/ImageLoader'; import ImageLoader from '../../modules/ImageLoader';
@@ -131,7 +130,7 @@ class Image extends Component {
super(props, context); super(props, context);
// If an image has been loaded before, render it immediately // If an image has been loaded before, render it immediately
const uri = resolveAssetSource(props.source); const uri = resolveAssetSource(props.source);
const shouldDisplaySource = ImageUriCache.has(uri) || !canUseDOM; const shouldDisplaySource = ImageUriCache.has(uri);
this.state = { shouldDisplaySource }; this.state = { shouldDisplaySource };
this._imageState = getImageState(uri, shouldDisplaySource); this._imageState = getImageState(uri, shouldDisplaySource);
shouldDisplaySource && ImageUriCache.add(uri); shouldDisplaySource && ImageUriCache.add(uri);