react-frame-component 5.2.2-alpha.0 → 5.2.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Frame.js +16 -6
- package/package.json +1 -1
package/lib/Frame.js
CHANGED
|
@@ -60,9 +60,17 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
_this.handleLoad = function () {
|
|
63
|
-
_this.
|
|
63
|
+
clearInterval(_this.loadCheck);
|
|
64
|
+
// Bail update as some browsers will trigger on both DOMContentLoaded & onLoad ala firefox
|
|
65
|
+
if (!_this.state.iframeLoaded) {
|
|
66
|
+
_this.setState({ iframeLoaded: true });
|
|
67
|
+
}
|
|
64
68
|
};
|
|
65
69
|
|
|
70
|
+
_this.loadCheck = setInterval(function loadCheckCallback() {
|
|
71
|
+
this.handleLoad();
|
|
72
|
+
}, 500);
|
|
73
|
+
|
|
66
74
|
_this._isMounted = false;
|
|
67
75
|
_this.nodeRef = _react2.default.createRef();
|
|
68
76
|
_this.state = { iframeLoaded: false };
|
|
@@ -75,9 +83,6 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
75
83
|
this._isMounted = true;
|
|
76
84
|
|
|
77
85
|
var doc = this.getDoc();
|
|
78
|
-
if (doc && doc.readyState === 'complete') {
|
|
79
|
-
this.forceUpdate();
|
|
80
|
-
}
|
|
81
86
|
|
|
82
87
|
if (doc) {
|
|
83
88
|
this.nodeRef.current.contentWindow.addEventListener('DOMContentLoaded', this.handleLoad);
|
|
@@ -88,7 +93,7 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
88
93
|
value: function componentWillUnmount() {
|
|
89
94
|
this._isMounted = false;
|
|
90
95
|
|
|
91
|
-
this.nodeRef.current.removeEventListener('
|
|
96
|
+
this.nodeRef.current.removeEventListener('DOMContentLoaded', this.handleLoad);
|
|
92
97
|
}
|
|
93
98
|
}, {
|
|
94
99
|
key: 'getDoc',
|
|
@@ -104,6 +109,10 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
104
109
|
}
|
|
105
110
|
return doc.body.children[0];
|
|
106
111
|
}
|
|
112
|
+
|
|
113
|
+
// In certain situations on a cold cache DOMContentLoaded never gets called
|
|
114
|
+
// fallback to an interval to check if that's the case
|
|
115
|
+
|
|
107
116
|
}, {
|
|
108
117
|
key: 'renderFrameContents',
|
|
109
118
|
value: function renderFrameContents() {
|
|
@@ -155,9 +164,10 @@ var Frame = exports.Frame = function (_Component) {
|
|
|
155
164
|
delete props.contentDidMount;
|
|
156
165
|
delete props.contentDidUpdate;
|
|
157
166
|
delete props.forwardedRef;
|
|
167
|
+
|
|
158
168
|
return _react2.default.createElement(
|
|
159
169
|
'iframe',
|
|
160
|
-
_extends({}, props, { ref: this.setRef }),
|
|
170
|
+
_extends({}, props, { ref: this.setRef, onLoad: this.handleLoad }),
|
|
161
171
|
this.state.iframeLoaded && this.renderFrameContents()
|
|
162
172
|
);
|
|
163
173
|
}
|
package/package.json
CHANGED