rc-upload
Advanced tools
Comparing version 1.6.0 to 1.6.4
@@ -55,3 +55,8 @@ 'use strict'; | ||
try { | ||
response = this.getIframeDocument().body.innerHTML; | ||
var doc = this.getIframeDocument(); | ||
var script = doc.getElementsByTagName('script')[0]; | ||
if (script && script.parentNode === doc.body) { | ||
doc.body.removeChild(script); | ||
} | ||
response = doc.body.innerHTML; | ||
props.onSuccess(response, eventFile); | ||
@@ -94,3 +99,3 @@ } catch (err) { | ||
getIframeNode: function getIframeNode() { | ||
return _react2['default'].findDOMNode(this.refs.iframe); | ||
return _react2['default'].findDOMNode(this).firstChild; | ||
}, | ||
@@ -118,4 +123,10 @@ | ||
getIframeHTML: function getIframeHTML() { | ||
return '\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <style>\n body,html {padding:0;margin:0;border:0;overflow:hidden;}\n </style>\n </head>\n <body>\n <form method="post"\n encType="multipart/form-data"\n action="' + this.props.action + '" id="form" style="display:block;height:9999px;position:relative;overflow:hidden;">\n <input id="input" type="file"\n name="' + this.props.name + '"\n style="position:absolute;top:0;right:0;height:9999px;font-size:9999px;cursor:pointer;"/>\n <span id="data"></span>\n </form>\n </body>\n </html>\n '; | ||
getIframeHTML: function getIframeHTML(domain) { | ||
var domainScript = ''; | ||
var domainInput = ''; | ||
if (domain) { | ||
domainScript = '<script>document.domain="' + domain + '";</script>'; | ||
domainInput = '<input name="_documentDomain" value="' + domain + '" />'; | ||
} | ||
return '\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <style>\n body,html {padding:0;margin:0;border:0;overflow:hidden;}\n </style>\n ' + domainScript + '\n </head>\n <body>\n <form method="post"\n encType="multipart/form-data"\n action="' + this.props.action + '" id="form" style="display:block;height:9999px;position:relative;overflow:hidden;">\n <input id="input" type="file"\n name="' + this.props.name + '"\n style="position:absolute;top:0;right:0;height:9999px;font-size:9999px;cursor:pointer;"/>\n ' + domainInput + '\n <span id="data"></span>\n </form>\n </body>\n </html>\n '; | ||
}, | ||
@@ -134,8 +145,24 @@ | ||
initIframeSrc: function initIframeSrc() { | ||
if (this.domain) { | ||
this.getIframeNode().src = 'javascript:void((function(){\n var d = document;\n d.open();\n d.domain=\'' + this.domain + '\';\n d.write(\'\');\n d.close();\n })())'; | ||
} | ||
}, | ||
initIframe: function initIframe() { | ||
var iframeNode = this.getIframeNode(); | ||
var win = iframeNode.contentWindow; | ||
var doc = win.document; | ||
var doc = undefined; | ||
this.domain = this.domain || ''; | ||
this.initIframeSrc(); | ||
try { | ||
doc = win.document; | ||
} catch (e) { | ||
this.domain = document.domain; | ||
this.initIframeSrc(); | ||
win = iframeNode.contentWindow; | ||
doc = win.document; | ||
} | ||
doc.open('text/html', 'replace'); | ||
doc.write(this.getIframeHTML()); | ||
doc.write(this.getIframeHTML(this.domain)); | ||
doc.close(); | ||
@@ -142,0 +169,0 @@ this.getFormInputNode().onchange = this.onChange; |
{ | ||
"name": "rc-upload", | ||
"version": "1.6.0", | ||
"version": "1.6.4", | ||
"description": "upload ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -72,4 +72,17 @@ # rc-upload | ||
### Note | ||
if run at ie and set document.domain, then server should output document.domain according to _documentDomain parameter | ||
```js | ||
var ret = ''; | ||
if(postData._documentDomain){ | ||
ret+='<script>document.domain="'+postData._documentDomain+'";</script>' | ||
} | ||
this.body = ret +'{"url":"xx.jpq"}'; | ||
``` | ||
## License | ||
rc-upload is released under the MIT license. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15072
324
88
0