react-html-element
Advanced tools
Comparing version 1.2.0-cdf5e.0 to 2.0.0-0
@@ -0,1 +1,12 @@ | ||
# [2.2.0](https://github.com/WTW-IM/react-html-element/compare/v2.1.0...v2.2.0) (2021-01-12) | ||
### Build | ||
* updating vulnerable build dependencies ([cdf5e6a](https://github.com/WTW-IM/react-html-element/commit/cdf5e6a4520ef3fe0284c99983e9e428240f0986)) | ||
### Update | ||
* importing es5 polyfills by default ([3566c5b](https://github.com/WTW-IM/react-html-element/commit/3566c5ba9deffb304bbba91ced5d92c6d26672a2)) | ||
# [2.1.0](https://github.com/WTW-IM/react-html-element/compare/v2.0.0...v2.1.0) (2020-11-20) | ||
@@ -2,0 +13,0 @@ |
@@ -0,1 +1,2 @@ | ||
import ReactDOM from 'react-dom'; | ||
declare class ReactHTMLElement extends HTMLElement { | ||
@@ -5,7 +6,5 @@ private _mountPoint?; | ||
private mountSelector; | ||
private retargetCleanupFunction; | ||
get mountPoint(): Element; | ||
set mountPoint(mount: Element); | ||
get retargetCleanup(): () => void; | ||
set retargetCleanup(cleanupFunction: () => void); | ||
render(app: Parameters<ReactDOM.Renderer>[0][number]): ReturnType<ReactDOM.Renderer>; | ||
disconnectedCallback(): void; | ||
@@ -12,0 +11,0 @@ constructor(template?: string, mountSelector?: string); |
@@ -6,3 +6,3 @@ "use strict"; | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -21,14 +21,2 @@ }; | ||
var react_dom_1 = __importDefault(require("react-dom")); | ||
var forcedRetargeting_1 = __importDefault(require("./forcedRetargeting")); | ||
// See https://github.com/facebook/react/issues/9242#issuecomment-543117675 | ||
function retargetReactEvents(container, shadow) { | ||
Object.defineProperty(container, 'ownerDocument', { value: shadow }); | ||
/* eslint-disable no-param-reassign */ | ||
shadow.defaultView = window; | ||
shadow.createElement = function (tagName, options) { return document.createElement(tagName, options); }; | ||
shadow.createElementNS = function (ns, tagName, options) { return document.createElementNS(ns, tagName, options); }; | ||
shadow.createTextNode = function (text) { return document.createTextNode(text); }; | ||
return forcedRetargeting_1.default(shadow); | ||
/* eslint-enable no-param-reassign */ | ||
} | ||
var ReactHTMLElement = /** @class */ (function (_super) { | ||
@@ -42,3 +30,2 @@ __extends(ReactHTMLElement, _super); | ||
_this.mountSelector = mountSelector; | ||
_this.retargetCleanupFunction = function () { }; | ||
return _this; | ||
@@ -53,3 +40,2 @@ } | ||
this._mountPoint = shadow.querySelector(this.mountSelector); | ||
this.retargetCleanup = retargetReactEvents(this._mountPoint, shadow); | ||
return this._mountPoint; | ||
@@ -59,25 +45,13 @@ }, | ||
this._mountPoint = mount; | ||
if (this.shadowRoot) { | ||
this.retargetCleanup = retargetReactEvents(mount, this.shadowRoot); | ||
} | ||
}, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(ReactHTMLElement.prototype, "retargetCleanup", { | ||
get: function () { | ||
return this.retargetCleanupFunction; | ||
}, | ||
set: function (cleanupFunction) { | ||
// Ensure that we cleanup an old listeners before we forget the cleanup function. | ||
this.retargetCleanup(); | ||
this.retargetCleanupFunction = cleanupFunction; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
ReactHTMLElement.prototype.render = function (app) { | ||
// eslint-disable-next-line react/no-render-return-value | ||
return react_dom_1.default.render(app, this.mountPoint); | ||
}; | ||
ReactHTMLElement.prototype.disconnectedCallback = function () { | ||
if (!this._mountPoint) | ||
return; | ||
this.retargetCleanup(); | ||
react_dom_1.default.unmountComponentAtNode(this._mountPoint); | ||
@@ -84,0 +58,0 @@ }; |
{ | ||
"name": "react-html-element", | ||
"version": "1.2.0-cdf5e.0", | ||
"version": "2.0.0-0", | ||
"description": "An HTMLElement extension that provides a simple setup for Web Components using React.", | ||
@@ -47,12 +47,12 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"react": "^16.13.0", | ||
"react-dom": "^16.13.0" | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9.0", | ||
"@babel/preset-env": "^7.9.0", | ||
"@babel/preset-react": "^7.9.4", | ||
"@babel/preset-typescript": "^7.9.0", | ||
"@babel/core": "^7.12.10", | ||
"@babel/plugin-proposal-class-properties": "^7.12.1", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.12.1", | ||
"@babel/preset-env": "^7.12.11", | ||
"@babel/preset-react": "^7.12.10", | ||
"@babel/preset-typescript": "^7.12.7", | ||
"@commitlint/cli": "^11.0.0", | ||
@@ -62,26 +62,26 @@ "@commitlint/config-conventional": "^11.0.0", | ||
"@semantic-release/git": "^9.0.0", | ||
"@testing-library/dom": "^7.1.1", | ||
"@testing-library/jest-dom": "^5.1.1", | ||
"@testing-library/react": "^10.0.1", | ||
"@types/jest": "^25.1.4", | ||
"@types/react-dom": "^16.9.5", | ||
"@typescript-eslint/eslint-plugin": "^2.24.0", | ||
"@typescript-eslint/parser": "^2.24.0", | ||
"conventional-changelog-eslint": "^3.0.4", | ||
"eslint": "^6.5.1", | ||
"eslint-config-airbnb-typescript": "^7.2.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-react": "^7.19.0", | ||
"eslint-plugin-react-hooks": "^2.5.1", | ||
"husky": "^4.2.3", | ||
"jest": "^25.1.0", | ||
"@testing-library/dom": "^7.29.4", | ||
"@testing-library/jest-dom": "^5.11.9", | ||
"@testing-library/react": "^11.2.3", | ||
"@types/jest": "^26.0.20", | ||
"@types/react-dom": "^17.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.14.1", | ||
"@typescript-eslint/parser": "^4.14.1", | ||
"conventional-changelog-eslint": "^3.0.9", | ||
"eslint": "^7.18.0", | ||
"eslint-config-airbnb-typescript": "^12.0.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"husky": "^4.3.8", | ||
"jest": "^26.6.3", | ||
"jest-environment-jsdom-sixteen": "^1.0.3", | ||
"lint-staged": "^10.0.8", | ||
"prettier": "1.19.1", | ||
"react": "^16.13.0", | ||
"react-dom": "^16.13.0", | ||
"semantic-release": "^17.3.1", | ||
"typescript": "^3.8.3" | ||
"lint-staged": "^10.5.3", | ||
"prettier": "2.2.1", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"semantic-release": "^17.3.7", | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -88,0 +88,0 @@ "dependencies": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15073
7
79