New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-frame-component

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-frame-component - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

25

index.js

@@ -65,3 +65,3 @@ var React = require('react');

var doc = ReactDOM.findDOMNode(this).contentDocument;
var doc = this.getDoc();
if(doc && doc.readyState === 'complete') {

@@ -87,9 +87,4 @@ var contents = React.createElement('div',

var callback = initialRender ? this.props.contentDidMount : this.props.contentDidUpdate;
var mountTarget;
var mountTarget = this.getMountTarget();
if(this.props.mountTarget) {
mountTarget = doc.querySelector(this.props.mountTarget);
} else {
mountTarget = doc.body.children[0];
}

@@ -103,2 +98,14 @@ ReactDOM.unstable_renderSubtreeIntoContainer(this, contents, mountTarget, callback);

},
getMountTarget: function() {
var doc = this.getDoc();
if(this.props.mountTarget) {
return doc.querySelector(this.props.mountTarget);
}
return doc.body.children[0];
},
getDoc: function() {
return ReactDOM.findDOMNode(this).contentDocument;
},
componentDidUpdate: function() {

@@ -110,5 +117,5 @@ this.renderFrameContents();

var doc = ReactDOM.findDOMNode(this).contentDocument;
var doc = this.getDoc();
if (doc) {
ReactDOM.unmountComponentAtNode(doc.body);
ReactDOM.unmountComponentAtNode(this.getMountTarget());
}

@@ -115,0 +122,0 @@ }

{
"name": "react-frame-component",
"version": "0.6.4",
"version": "0.6.5",
"description": "React component to wrap your application or component in an iFrame for encapsulation purposes",

@@ -40,4 +40,4 @@ "main": "index.js",

"dependencies": {
"object-assign": "^3.0.0"
"object-assign": "^4.1.0"
}
}

@@ -256,2 +256,22 @@ "use strict";

});
it("should return first child element of the `body` on call to `this.getMountTarget()` if `props.mountTarget` was not passed in", function () {
div = document.body.appendChild(document.createElement('div'));
var frame = ReactDOM.render(<Frame />, div),
body = ReactDOM.findDOMNode(frame).contentDocument.body;
expect(Frame.prototype.getMountTarget.call(frame)).toEqual(body.children[0]);
});
it("should return resolved `props.mountTarget` node on call to `this.getMountTarget()` if `props.mountTarget` was passed in", function () {
div = document.body.appendChild(document.createElement('div'));
var initialContent = '<!DOCTYPE html><html><head></head><body><div></div><div id="container"></div></body></html>';
var frame = ReactDOM.render(<Frame initialContent={initialContent} mountTarget='#container' />, div),
body = ReactDOM.findDOMNode(frame).contentDocument.body;
div = document.body.appendChild(document.createElement('div'));
expect(Frame.prototype.getMountTarget.call(frame)).toEqual(body.querySelector('#container'));
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc