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
 import Immutable from 'immutable';
5
 import Immutable from 'immutable';
6
 
6
 
7
 function appendFilesToHead(files, script) {
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
     const { rel, type, href } = file;
9
     const { rel, type, href } = file;
13
     return `
10
     return `
14
             var link  = document.createElement('link');
11
             var link  = document.createElement('link');
71
   const { hasIframe, files, customStyle, customScript, style } = getReloadRelatedData(props);
68
   const { hasIframe, files, customStyle, customScript, style } = getReloadRelatedData(props);
72
   const baseScript = getBaseScript(style);
69
   const baseScript = getBaseScript(style);
73
   let script = hasIframe && getIframeBaseScript ? getIframeBaseScript(style) : baseScript;
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
   script = appendStylesToHead(customStyle, script);
72
   script = appendStylesToHead(customStyle, script);
76
   customScript && (script = customScript + script);
73
   customScript && (script = customScript + script);
77
   return script;
74
   return script;