Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

styled-jsx

Package Overview
Dependencies
Maintainers
7
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

styled-jsx - npm Package Compare versions

Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2

72

dist/style.js
"use strict";
exports.__esModule = true;
exports["default"] = JSXStyle;
exports.flush = flush;
exports["default"] = void 0;

@@ -13,59 +13,27 @@ var _react = require("react");

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
var styleSheetRegistry = new _stylesheetRegistry["default"]();
var JSXStyle = /*#__PURE__*/function (_Component) {
_inheritsLoose(JSXStyle, _Component);
function JSXStyle(props) {
var _this;
_this = _Component.call(this, props) || this;
_this.prevProps = {};
return _this;
function JSXStyle(props) {
if (typeof window === 'undefined') {
styleSheetRegistry.add(props);
return null;
}
JSXStyle.dynamic = function dynamic(info) {
return info.map(function (tagInfo) {
var baseId = tagInfo[0];
var props = tagInfo[1];
return styleSheetRegistry.computeId(baseId, props);
}).join(' ');
} // probably faster than PureComponent (shallowEqual)
;
(0, _react.useLayoutEffect)(function () {
styleSheetRegistry.add(props);
return function () {
styleSheetRegistry.remove(props);
}; // props.children can be string[], will be striped since id is identical
}, [props.id, String(props.dynamic)]);
return null;
}
var _proto = JSXStyle.prototype;
JSXStyle.dynamic = function (info) {
return info.map(function (tagInfo) {
var baseId = tagInfo[0];
var props = tagInfo[1];
return styleSheetRegistry.computeId(baseId, props);
}).join(' ');
};
_proto.shouldComponentUpdate = function shouldComponentUpdate(otherProps) {
return this.props.id !== otherProps.id || // We do this check because `dynamic` is an array of strings or undefined.
// These are the computed values for dynamic styles.
String(this.props.dynamic) !== String(otherProps.dynamic);
};
_proto.componentWillUnmount = function componentWillUnmount() {
styleSheetRegistry.remove(this.props);
};
_proto.render = function render() {
// This is a workaround to make the side effect async safe in the "render" phase.
// See https://github.com/zeit/styled-jsx/pull/484
if (this.shouldComponentUpdate(this.prevProps)) {
// Updates
if (this.prevProps.id) {
styleSheetRegistry.remove(this.prevProps);
}
styleSheetRegistry.add(this.props);
this.prevProps = this.props;
}
return null;
};
return JSXStyle;
}(_react.Component);
exports["default"] = JSXStyle;
function flush() {

@@ -72,0 +40,0 @@ var cssRules = styleSheetRegistry.cssRules();

{
"name": "styled-jsx",
"version": "4.0.0-alpha.1",
"version": "4.0.0-alpha.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "vercel/styled-jsx",

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