react-frame-component 5.2.2-alpha.1 → 5.2.2

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/index.d.ts CHANGED
@@ -1 +1,31 @@
1
- declare module 'react-frame-component';
1
+ declare module 'react-frame-component' {
2
+ import * as React from 'react';
3
+
4
+ export interface FrameComponentProps
5
+ extends React.IframeHTMLAttributes<HTMLIFrameElement> {
6
+ head?: React.ReactNode | undefined;
7
+ mountTarget?: string | undefined;
8
+ initialContent?: string | undefined;
9
+ contentDidMount?: (() => void) | undefined;
10
+ contentDidUpdate?: (() => void) | undefined;
11
+ children: React.ReactNode;
12
+ ref?: React.Ref<FrameComponent>;
13
+ }
14
+
15
+ export default class FrameComponent extends React.Component<
16
+ FrameComponentProps
17
+ > {}
18
+
19
+ export interface FrameContextProps {
20
+ document?: HTMLDocument;
21
+ window?: Window;
22
+ }
23
+
24
+ export const FrameContext: React.Context<FrameContextProps>;
25
+
26
+ export const FrameContextProvider: React.Provider<FrameContextProps>;
27
+
28
+ export const FrameContextConsumer: React.Consumer<FrameContextProps>;
29
+
30
+ export function useFrame(): FrameContextProps;
31
+ }
package/lib/Frame.js CHANGED
@@ -60,10 +60,7 @@ var Frame = exports.Frame = function (_Component) {
60
60
  };
61
61
 
62
62
  _this.handleLoad = function () {
63
- // Bail update as some browsers will trigger on both DOMContentLoaded & onLoad ala firefox
64
- if (!_this.state.iframeLoaded) {
65
- _this.setState({ iframeLoaded: true });
66
- }
63
+ _this.setState({ iframeLoaded: true });
67
64
  };
68
65
 
69
66
  _this._isMounted = false;
@@ -78,9 +75,10 @@ var Frame = exports.Frame = function (_Component) {
78
75
  this._isMounted = true;
79
76
 
80
77
  var doc = this.getDoc();
81
-
82
- if (doc) {
83
- this.nodeRef.current.contentWindow.addEventListener('DOMContentLoaded', this.handleLoad);
78
+ if (doc && doc.readyState === 'complete') {
79
+ this.forceUpdate();
80
+ } else {
81
+ this.nodeRef.current.addEventListener('load', this.handleLoad);
84
82
  }
85
83
  }
86
84
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-frame-component",
3
- "version": "5.2.2-alpha.1",
3
+ "version": "5.2.2",
4
4
  "description": "React component to wrap your application or component in an iFrame for encapsulation purposes",
5
5
  "main": "lib/index.js",
6
6
  "files": [