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

react-pushstate-anchor

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pushstate-anchor - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

8

es/index.js

@@ -26,3 +26,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

_this.state = { location: window.location };
_this.state = { location: null };
_this.history = createHistory();

@@ -35,2 +35,6 @@ _this.history.listen(function (location) {

PushStateAnchorProvider.prototype.componentDidMount = function componentDidMount() {
this.setState({ location: window.location });
};
PushStateAnchorProvider.prototype.render = function render() {

@@ -105,3 +109,3 @@ return React.createElement(

function (value) {
return props.children(value.location);
return value.location && props.children(value.location);
}

@@ -108,0 +112,0 @@ );

@@ -38,3 +38,3 @@ 'use strict';

_this.state = { location: window.location };
_this.state = { location: null };
_this.history = (0, _createBrowserHistory2.default)();

@@ -47,2 +47,6 @@ _this.history.listen(function (location) {

PushStateAnchorProvider.prototype.componentDidMount = function componentDidMount() {
this.setState({ location: window.location });
};
PushStateAnchorProvider.prototype.render = function render() {

@@ -117,3 +121,3 @@ return _react2.default.createElement(

function (value) {
return props.children(value.location);
return value.location && props.children(value.location);
}

@@ -120,0 +124,0 @@ );

{
"name": "react-pushstate-anchor",
"version": "0.1.4",
"version": "0.2.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "module": "es/index.js",

@@ -213,3 +213,3 @@ (function (global, factory) {

_this.state = { location: window.location };
_this.state = { location: null };
_this.history = createHistory();

@@ -222,2 +222,6 @@ _this.history.listen(function (location) {

PushStateAnchorProvider.prototype.componentDidMount = function componentDidMount() {
this.setState({ location: window.location });
};
PushStateAnchorProvider.prototype.render = function render() {

@@ -292,3 +296,3 @@ return React__default.createElement(

function (value) {
return props.children(value.location);
return value.location && props.children(value.location);
}

@@ -295,0 +299,0 @@ );

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("history/createBrowserHistory")):"function"==typeof define&&define.amd?define(["exports","react","history/createBrowserHistory"],e):e(t.ReactPushStateAnchor={},t.React,t.createHistory)}(this,function(t,e,n){"use strict";var r="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;!function(){function t(t){this.value=t}function e(e){var n,r;function o(n,r){try{var c=e[n](r),u=c.value;u instanceof t?Promise.resolve(u.value).then(function(t){o("next",t)},function(t){o("throw",t)}):i(c.done?"return":"normal",c.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":n.resolve({value:e,done:!0});break;case"throw":n.reject(e);break;default:n.resolve({value:e,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}this._invoke=function(t,e){return new Promise(function(i,c){var u={key:t,arg:e,resolve:i,reject:c,next:null};r?r=r.next=u:(n=r=u,o(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},u=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},a=r.createContext("push-state-anchor"),s=a.Provider,l=a.Consumer,f=function(t){function e(){o(this,e);var r=u(this,t.call(this));return r.state={location:window.location},r.history=n(),r.history.listen(function(t){return r.setState({location:t})}),r}return c(e,t),e.prototype.render=function(){return r.createElement(s,{value:i({history:this.history},this.state)},this.props.children)},e}(e.Component),p=function(t){function e(){o(this,e);var n=u(this,t.call(this));return n.state={clientReady:!1},n.interceptOnClick=n.interceptOnClick.bind(n),n}return c(e,t),e.prototype.componentDidMount=function(){this.setState({clientReady:!0})},e.prototype.interceptOnClick=function(t,e){t.preventDefault(),e.history.push(this.props.href)},e.prototype.render=function(){var t=this,e=this.props,n=e.onClick,o=function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}(e,["onClick"]);return r.createElement(l,null,function(e){return r.createElement("a",i({onClick:function(r){t.state.clientReady?t.interceptOnClick(r,e):n(r)}},o),o.children)})},e}(e.Component);t.PushStateAnchorProvider=f,t.PushStateAnchor=p,t.PushStateLocation=function(t){return r.createElement(l,null,function(e){return t.children(e.location)})},Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("history/createBrowserHistory")):"function"==typeof define&&define.amd?define(["exports","react","history/createBrowserHistory"],e):e(t.ReactPushStateAnchor={},t.React,t.createHistory)}(this,function(t,e,n){"use strict";var r="default"in e?e.default:e;n=n&&n.hasOwnProperty("default")?n.default:n;!function(){function t(t){this.value=t}function e(e){var n,r;function o(n,r){try{var c=e[n](r),u=c.value;u instanceof t?Promise.resolve(u.value).then(function(t){o("next",t)},function(t){o("throw",t)}):i(c.done?"return":"normal",c.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":n.resolve({value:e,done:!0});break;case"throw":n.reject(e);break;default:n.resolve({value:e,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}this._invoke=function(t,e){return new Promise(function(i,c){var u={key:t,arg:e,resolve:i,reject:c,next:null};r?r=r.next=u:(n=r=u,o(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},u=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},a=r.createContext("push-state-anchor"),s=a.Provider,l=a.Consumer,f=function(t){function e(){o(this,e);var r=u(this,t.call(this));return r.state={location:null},r.history=n(),r.history.listen(function(t){return r.setState({location:t})}),r}return c(e,t),e.prototype.componentDidMount=function(){this.setState({location:window.location})},e.prototype.render=function(){return r.createElement(s,{value:i({history:this.history},this.state)},this.props.children)},e}(e.Component),p=function(t){function e(){o(this,e);var n=u(this,t.call(this));return n.state={clientReady:!1},n.interceptOnClick=n.interceptOnClick.bind(n),n}return c(e,t),e.prototype.componentDidMount=function(){this.setState({clientReady:!0})},e.prototype.interceptOnClick=function(t,e){t.preventDefault(),e.history.push(this.props.href)},e.prototype.render=function(){var t=this,e=this.props,n=e.onClick,o=function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}(e,["onClick"]);return r.createElement(l,null,function(e){return r.createElement("a",i({onClick:function(r){t.state.clientReady?t.interceptOnClick(r,e):n(r)}},o),o.children)})},e}(e.Component);t.PushStateAnchorProvider=f,t.PushStateAnchor=p,t.PushStateLocation=function(t){return r.createElement(l,null,function(e){return e.location&&t.children(e.location)})},Object.defineProperty(t,"__esModule",{value:!0})});
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