|  | @@ -6,7 +6,7 @@ import { Animated, StyleSheet, ViewPropTypes, WebView } from 'react-native';
 | 
	
		
			
			| 6 | 6 |  
 | 
	
		
			
			| 7 | 7 |  import PropTypes from 'prop-types';
 | 
	
		
			
			| 8 | 8 |  
 | 
	
		
			
			| 9 |  | -import { needChangeSource, getWidth, getScript, handleSizeUpdated, domMutationObserveScript } from './common.js';
 | 
	
		
			
			|  | 9 | +import { isScriptChanged, getSize, getWidth, getScript, handleSizeUpdated, domMutationObserveScript } from './common.js';
 | 
	
		
			
			| 10 | 10 |  
 | 
	
		
			
			| 11 | 11 |  export default class AutoHeightWebView extends PureComponent {
 | 
	
		
			
			| 12 | 12 |    static propTypes = {
 | 
	
	
		
			
			|  | @@ -53,6 +53,7 @@ export default class AutoHeightWebView extends PureComponent {
 | 
	
		
			
			| 53 | 53 |      const { enableAnimation, style } = props;
 | 
	
		
			
			| 54 | 54 |      enableAnimation && (this.opacityAnimatedValue = new Animated.Value(0));
 | 
	
		
			
			| 55 | 55 |      this.state = {
 | 
	
		
			
			|  | 56 | +      isScriptChanged: false,
 | 
	
		
			
			| 56 | 57 |        width: getWidth(style),
 | 
	
		
			
			| 57 | 58 |        height: style && style.height ? style.height : 0,
 | 
	
		
			
			| 58 | 59 |        script: getScript(props, getBaseScript, getIframeBaseScript)
 | 
	
	
		
			
			|  | @@ -60,13 +61,10 @@ export default class AutoHeightWebView extends PureComponent {
 | 
	
		
			
			| 60 | 61 |    }
 | 
	
		
			
			| 61 | 62 |  
 | 
	
		
			
			| 62 | 63 |    componentWillReceiveProps(nextProps) {
 | 
	
		
			
			| 63 |  | -    if (nextProps.style) {
 | 
	
		
			
			| 64 |  | -      const { width, height } = nextProps.style;
 | 
	
		
			
			| 65 |  | -      width && this.setState({ width });
 | 
	
		
			
			| 66 |  | -      height && this.setState({ height });
 | 
	
		
			
			| 67 |  | -    }
 | 
	
		
			
			| 68 |  | -    this.setState({ script: getScript(nextProps, getBaseScript, getIframeBaseScript) });
 | 
	
		
			
			| 69 |  | -    this.needChangeSource = needChangeSource(nextProps, this.props);
 | 
	
		
			
			|  | 64 | +    const size = getSize(nextProps, this.props);
 | 
	
		
			
			|  | 65 | +    size && this.setState(size); 
 | 
	
		
			
			|  | 66 | +    this.isScriptChanged = isScriptChanged(nextProps, this.props);
 | 
	
		
			
			|  | 67 | +    this.isScriptChanged && this.setState({ script: getScript(nextProps, getBaseScript, getIframeBaseScript) });
 | 
	
		
			
			| 70 | 68 |    }
 | 
	
		
			
			| 71 | 69 |  
 | 
	
		
			
			| 72 | 70 |    handleNavigationStateChange = navState => {
 | 
	
	
		
			
			|  | @@ -121,7 +119,7 @@ export default class AutoHeightWebView extends PureComponent {
 | 
	
		
			
			| 121 | 119 |        scrollEnabled
 | 
	
		
			
			| 122 | 120 |      } = this.props;
 | 
	
		
			
			| 123 | 121 |      let webViewSource = Object.assign({}, source, { baseUrl: 'web/' });
 | 
	
		
			
			| 124 |  | -    if (this.needChangeSource) {
 | 
	
		
			
			|  | 122 | +    if (this.isScriptChanged) {
 | 
	
		
			
			| 125 | 123 |        this.changeSourceFlag = !this.changeSourceFlag;
 | 
	
		
			
			| 126 | 124 |        webViewSource = Object.assign(webViewSource, { changeSourceFlag: this.changeSourceFlag });
 | 
	
		
			
			| 127 | 125 |      }
 | 
	
	
		
			
			|  | @@ -173,7 +171,7 @@ const commonScript = `
 | 
	
		
			
			| 173 | 171 |      window.addEventListener('resize', updateSize);
 | 
	
		
			
			| 174 | 172 |      `;
 | 
	
		
			
			| 175 | 173 |  
 | 
	
		
			
			| 176 |  | -const getSize = `
 | 
	
		
			
			|  | 174 | +const getCurrentSize = `
 | 
	
		
			
			| 177 | 175 |      function getSize(container) {
 | 
	
		
			
			| 178 | 176 |        var height = container.clientHeight || document.body.offsetHeight;
 | 
	
		
			
			| 179 | 177 |        var width = container.clientWidth || document.body.offsetWidth;
 | 
	
	
		
			
			|  | @@ -187,7 +185,7 @@ const getSize = `
 | 
	
		
			
			| 187 | 185 |  function getBaseScript(style) {
 | 
	
		
			
			| 188 | 186 |    return `
 | 
	
		
			
			| 189 | 187 |      ;
 | 
	
		
			
			| 190 |  | -    ${getSize}
 | 
	
		
			
			|  | 188 | +    ${getCurrentSize}
 | 
	
		
			
			| 191 | 189 |      (function () {
 | 
	
		
			
			| 192 | 190 |          var height = 0;
 | 
	
		
			
			| 193 | 191 |          var width = ${getWidth(style)};
 | 
	
	
		
			
			|  | @@ -214,7 +212,7 @@ function getBaseScript(style) {
 | 
	
		
			
			| 214 | 212 |  function getIframeBaseScript(style) {
 | 
	
		
			
			| 215 | 213 |    return `
 | 
	
		
			
			| 216 | 214 |      ;
 | 
	
		
			
			| 217 |  | -    ${getSize}
 | 
	
		
			
			|  | 215 | +    ${getCurrentSize}
 | 
	
		
			
			| 218 | 216 |      (function () {
 | 
	
		
			
			| 219 | 217 |          var height = 0;
 | 
	
		
			
			| 220 | 218 |          var width = ${getWidth(style)};
 |