Browse Source

fix appendFilesToHead issue for common

iou90 5 years ago
parent
commit
4e76126447
1 changed files with 2 additions and 5 deletions
  1. 2
    5
      autoHeightWebView/common.js

+ 2
- 5
autoHeightWebView/common.js View File

@@ -5,10 +5,7 @@ import { Dimensions } from 'react-native';
5 5
 import Immutable from 'immutable';
6 6
 
7 7
 function appendFilesToHead(files, script) {
8
-  if (!files) {
9
-    return script;
10
-  }
11
-  return files.reduceRight((file, combinedScript) => {
8
+  return files.reduceRight((combinedScript, file) => {
12 9
     const { rel, type, href } = file;
13 10
     return `
14 11
             var link  = document.createElement('link');
@@ -71,7 +68,7 @@ export function getScript(props, getBaseScript, getIframeBaseScript) {
71 68
   const { hasIframe, files, customStyle, customScript, style } = getReloadRelatedData(props);
72 69
   const baseScript = getBaseScript(style);
73 70
   let script = hasIframe && getIframeBaseScript ? getIframeBaseScript(style) : baseScript;
74
-  script = files ? appendFilesToHead(files, baseScript) : baseScript;
71
+  script = files && files.length > 0 ? appendFilesToHead(files, script) : script;
75 72
   script = appendStylesToHead(customStyle, script);
76 73
   customScript && (script = customScript + script);
77 74
   return script;