Skip to content

Commit

Permalink
fix: compile to es5
Browse files Browse the repository at this point in the history
  • Loading branch information
robbestad committed Apr 14, 2019
1 parent df82612 commit aa6620a
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 84 deletions.
24 changes: 12 additions & 12 deletions dist/cjs/__tests__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ var __importDefault =
return mod && mod.__esModule ? mod : { default: mod }
}
Object.defineProperty(exports, "__esModule", { value: true })
const react_1 = __importDefault(require("react"))
const iframe_1 = __importDefault(require("../iframe"))
const react_test_renderer_1 = __importDefault(require("react-test-renderer"))
test("Render default iframe", () => {
const component = react_test_renderer_1.default.create(
var react_1 = __importDefault(require("react"))
var iframe_1 = __importDefault(require("../iframe"))
var react_test_renderer_1 = __importDefault(require("react-test-renderer"))
test("Render default iframe", function() {
var component = react_test_renderer_1.default.create(
react_1.default.createElement(iframe_1.default, { position: "relative", url: "http://www.foobar.com" })
)
let tree = component.toJSON()
var tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
test("Render iframe with title", () => {
const component = react_test_renderer_1.default.create(
test("Render iframe with title", function() {
var component = react_test_renderer_1.default.create(
react_1.default.createElement(iframe_1.default, {
position: "relative",
title: "A foobared iframe",
Expand All @@ -30,13 +30,13 @@ test("Render iframe with title", () => {
className: "myIframeClass",
frameBorder: 2,
overflow: "auto",
onLoad: () => {
onLoad: function() {
console.log("hello")
},
onMouseOut: () => {
onMouseOut: function() {
console.log("goodbye")
},
onMouseOver: () => {
onMouseOver: function() {
console.log("hi")
},
display: "inline-block",
Expand All @@ -47,6 +47,6 @@ test("Render iframe with title", () => {
target: "_self"
})
)
let tree = component.toJSON()
var tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
78 changes: 46 additions & 32 deletions dist/cjs/iframe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
"use strict"
var __assign =
(this && this.__assign) ||
function() {
__assign =
Object.assign ||
function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i]
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]
}
return t
}
return __assign.apply(this, arguments)
}
var __importStar =
(this && this.__importStar) ||
function(mod) {
Expand All @@ -14,36 +28,35 @@ var __importDefault =
return mod && mod.__esModule ? mod : { default: mod }
}
Object.defineProperty(exports, "__esModule", { value: true })
const react_1 = __importStar(require("react"))
var react_1 = __importStar(require("react"))
// @ts-ignore
const object_assign_1 = __importDefault(require("object-assign"))
const Iframe = ({
url,
allowFullScreen,
position,
display,
height,
width,
overflow,
styles,
onLoad,
onMouseOver,
onMouseOut,
scrolling,
id,
frameBorder,
ariaHidden,
sandbox,
allow,
className,
title,
ariaLabel,
ariaLabelledby,
name,
target
}) => {
const iFrameRef = react_1.createRef()
const defaultProps = object_assign_1.default({
var object_assign_1 = __importDefault(require("object-assign"))
var Iframe = function(_a) {
var url = _a.url,
allowFullScreen = _a.allowFullScreen,
position = _a.position,
display = _a.display,
height = _a.height,
width = _a.width,
overflow = _a.overflow,
styles = _a.styles,
onLoad = _a.onLoad,
onMouseOver = _a.onMouseOver,
onMouseOut = _a.onMouseOut,
scrolling = _a.scrolling,
id = _a.id,
frameBorder = _a.frameBorder,
ariaHidden = _a.ariaHidden,
sandbox = _a.sandbox,
allow = _a.allow,
className = _a.className,
title = _a.title,
ariaLabel = _a.ariaLabel,
ariaLabelledby = _a.ariaLabelledby,
name = _a.name,
target = _a.target
var iFrameRef = react_1.createRef()
var defaultProps = object_assign_1.default({
ref: iFrameRef,
src: url,
target: target || "_parent",
Expand Down Expand Up @@ -73,12 +86,13 @@ const Iframe = ({
onMouseOver: onMouseOver || null,
onMouseOut: onMouseOut || null
})
let props = Object.create(null)
for (let prop of Object.keys(defaultProps)) {
var props = Object.create(null)
for (var _i = 0, _b = Object.keys(defaultProps); _i < _b.length; _i++) {
var prop = _b[_i]
if (defaultProps[prop] != null) {
props[prop] = defaultProps[prop]
}
}
return react_1.default.createElement("iframe", Object.assign({}, props))
return react_1.default.createElement("iframe", __assign({}, props))
}
exports.default = Iframe
18 changes: 9 additions & 9 deletions dist/es/__tests__/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react"
import Iframe from "../iframe"
import renderer from "react-test-renderer"
test("Render default iframe", () => {
const component = renderer.create(React.createElement(Iframe, { position: "relative", url: "http://www.foobar.com" }))
let tree = component.toJSON()
test("Render default iframe", function() {
var component = renderer.create(React.createElement(Iframe, { position: "relative", url: "http://www.foobar.com" }))
var tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
test("Render iframe with title", () => {
const component = renderer.create(
test("Render iframe with title", function() {
var component = renderer.create(
React.createElement(Iframe, {
position: "relative",
title: "A foobared iframe",
Expand All @@ -21,13 +21,13 @@ test("Render iframe with title", () => {
className: "myIframeClass",
frameBorder: 2,
overflow: "auto",
onLoad: () => {
onLoad: function() {
console.log("hello")
},
onMouseOut: () => {
onMouseOut: function() {
console.log("goodbye")
},
onMouseOver: () => {
onMouseOver: function() {
console.log("hi")
},
display: "inline-block",
Expand All @@ -38,6 +38,6 @@ test("Render iframe with title", () => {
target: "_self"
})
)
let tree = component.toJSON()
var tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
74 changes: 44 additions & 30 deletions dist/es/iframe.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
var __assign =
(this && this.__assign) ||
function() {
__assign =
Object.assign ||
function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i]
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]
}
return t
}
return __assign.apply(this, arguments)
}
import React, { createRef } from "react"
// @ts-ignore
import objectAssign from "object-assign"
const Iframe = ({
url,
allowFullScreen,
position,
display,
height,
width,
overflow,
styles,
onLoad,
onMouseOver,
onMouseOut,
scrolling,
id,
frameBorder,
ariaHidden,
sandbox,
allow,
className,
title,
ariaLabel,
ariaLabelledby,
name,
target
}) => {
const iFrameRef = createRef()
const defaultProps = objectAssign({
var Iframe = function(_a) {
var url = _a.url,
allowFullScreen = _a.allowFullScreen,
position = _a.position,
display = _a.display,
height = _a.height,
width = _a.width,
overflow = _a.overflow,
styles = _a.styles,
onLoad = _a.onLoad,
onMouseOver = _a.onMouseOver,
onMouseOut = _a.onMouseOut,
scrolling = _a.scrolling,
id = _a.id,
frameBorder = _a.frameBorder,
ariaHidden = _a.ariaHidden,
sandbox = _a.sandbox,
allow = _a.allow,
className = _a.className,
title = _a.title,
ariaLabel = _a.ariaLabel,
ariaLabelledby = _a.ariaLabelledby,
name = _a.name,
target = _a.target
var iFrameRef = createRef()
var defaultProps = objectAssign({
ref: iFrameRef,
src: url,
target: target || "_parent",
Expand Down Expand Up @@ -57,12 +70,13 @@ const Iframe = ({
onMouseOver: onMouseOver || null,
onMouseOut: onMouseOut || null
})
let props = Object.create(null)
for (let prop of Object.keys(defaultProps)) {
var props = Object.create(null)
for (var _i = 0, _b = Object.keys(defaultProps); _i < _b.length; _i++) {
var prop = _b[_i]
if (defaultProps[prop] != null) {
props[prop] = defaultProps[prop]
}
}
return React.createElement("iframe", Object.assign({}, props))
return React.createElement("iframe", __assign({}, props))
}
export default Iframe
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"experimentalDecorators": true,
"esModuleInterop": true,
"moduleResolution": "node",
"target": "es2015",
"target": "es5",
"module": "amd",
"jsx": "react",
"baseUrl": ""
Expand Down

0 comments on commit aa6620a

Please sign in to comment.