Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

universal-router-react

Package Overview
Dependencies
23
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.5 to 0.0.6

108

dom/Link.js

@@ -1,6 +0,7 @@

import React, {PropTypes} from 'react'
import { history as historyPropTypes } from '../shared/propTypes';
import React, { PropTypes } from 'react';
import { history as historyPropTypes } from '../../shared/propTypes';
const isModifiedEvent = (event) =>
!!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
var isModifiedEvent = function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
};

@@ -10,55 +11,72 @@ /**

*/
class Link extends React.Component {
static propTypes = {
onClick: PropTypes.func,
target: PropTypes.string,
replace: PropTypes.bool,
to: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]).isRequired
}
static defaultProps = {
replace: false
}
var Link = function (_React$Component) {
babelHelpers.inherits(Link, _React$Component);
static contextTypes = {
history: historyPropTypes.isRequired
}
function Link() {
var _ref;
handleClick = (event) => {
if (this.props.onClick)
this.props.onClick(event)
var _temp, _this, _ret;
if (
!event.defaultPrevented && // onClick prevented default
babelHelpers.classCallCheck(this, Link);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = babelHelpers.possibleConstructorReturn(this, (_ref = Link.__proto__ || Object.getPrototypeOf(Link)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) {
if (_this.props.onClick) _this.props.onClick(event);
if (!event.defaultPrevented && // onClick prevented default
event.button === 0 && // ignore right clicks
!this.props.target && // let browser handle "target=_blank" etc.
!_this.props.target && // let browser handle "target=_blank" etc.
!isModifiedEvent(event) // ignore clicks with modifier keys
) {
event.preventDefault()
) {
event.preventDefault();
const { history } = this.context
const { replace, to } = this.props
var history = _this.context.history;
var _this$props = _this.props,
replace = _this$props.replace,
to = _this$props.to;
if (replace) {
history.replace(to)
} else {
history.push(to)
}
}
if (replace) {
history.replace(to);
} else {
history.push(to);
}
}
}, _temp), babelHelpers.possibleConstructorReturn(_this, _ret);
}
render() {
const { replace, to, ...props } = this.props // eslint-disable-line no-unused-vars
babelHelpers.createClass(Link, [{
key: 'render',
value: function render() {
var _props = this.props,
replace = _props.replace,
to = _props.to,
props = babelHelpers.objectWithoutProperties(_props, ['replace', 'to']); // eslint-disable-line no-unused-vars
const href = this.context.router.history.createHref(
typeof to === 'string' ? { pathname: to } : to
)
var href = this.context.router.history.createHref(typeof to === 'string' ? { pathname: to } : to);
return <a {...props} onClick={this.handleClick} href={href}/>
}
}
return React.createElement('a', babelHelpers.extends({}, props, { onClick: this.handleClick, href: href }));
}
}]);
return Link;
}(React.Component);
export default Link
Link.propTypes = {
onClick: PropTypes.func,
target: PropTypes.string,
replace: PropTypes.bool,
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired
};
Link.defaultProps = {
replace: false
};
Link.contextTypes = {
history: historyPropTypes.isRequired
};
export default Link;
{
"name": "universal-router-react",
"version": "0.0.5",
"version": "0.0.6",
"description": "",
"main": "_dist/index.js",
"scripts": {
"build": "rollup -c"
"build": "npm run build:main && npm run build:platforms",
"build:main": "rollup -c",
"build:platforms": "babel platforms -d ."
},

@@ -20,2 +22,3 @@ "files": [

"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-external-helpers": "^6.22.0",

@@ -22,0 +25,0 @@ "babel-preset-es2015": "^6.24.1",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc