From 706dc9c92dd3dec869fc725ba53e8f86b289cd8b Mon Sep 17 00:00:00 2001 From: dicky Date: Thu, 15 Jun 2017 21:33:35 -0700 Subject: [PATCH] Fix issue #28 by unmounting route target before mounting a new one. --- WebApplication.Core.React/wwwroot/lib/dotnetify-react.js | 9 ++++++++- dist/dotnetify-react.js | 9 ++++++++- dist/dotnetify-react.min.js | 2 +- package.json | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/WebApplication.Core.React/wwwroot/lib/dotnetify-react.js b/WebApplication.Core.React/wwwroot/lib/dotnetify-react.js index a9ab88ed..efa169cc 100644 --- a/WebApplication.Core.React/wwwroot/lib/dotnetify-react.js +++ b/WebApplication.Core.React/wwwroot/lib/dotnetify-react.js @@ -151,7 +151,7 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify; }); dotnetify.react = $.extend(dotnetify.hasOwnProperty("react") ? dotnetify.react : {}, { - version: "1.0.2-beta", + version: "1.0.3-beta", viewModels: {}, plugins: {}, @@ -398,6 +398,13 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify; return; } + try { + _ReactDOM.unmountComponentAtNode(document.querySelector(iTargetSelector)); + } + catch (e) { + console.error(e); + } + try { var reactElement = _React.createElement(window[iReactClassName], iReactProps); _ReactDOM.render(reactElement, document.querySelector(iTargetSelector)); diff --git a/dist/dotnetify-react.js b/dist/dotnetify-react.js index a9ab88ed..efa169cc 100644 --- a/dist/dotnetify-react.js +++ b/dist/dotnetify-react.js @@ -151,7 +151,7 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify; }); dotnetify.react = $.extend(dotnetify.hasOwnProperty("react") ? dotnetify.react : {}, { - version: "1.0.2-beta", + version: "1.0.3-beta", viewModels: {}, plugins: {}, @@ -398,6 +398,13 @@ var dotnetify = typeof dotnetify === "undefined" ? {} : dotnetify; return; } + try { + _ReactDOM.unmountComponentAtNode(document.querySelector(iTargetSelector)); + } + catch (e) { + console.error(e); + } + try { var reactElement = _React.createElement(window[iReactClassName], iReactProps); _ReactDOM.render(reactElement, document.querySelector(iTargetSelector)); diff --git a/dist/dotnetify-react.min.js b/dist/dotnetify-react.min.js index 65855069..f582f619 100644 --- a/dist/dotnetify-react.min.js +++ b/dist/dotnetify-react.min.js @@ -1 +1 @@ -var dotnetify="undefined"==typeof dotnetify?{}:dotnetify;!function(a){"function"==typeof define&&define.amd?define(["react","react-dom","jquery","signalr"],a):"object"==typeof exports&&"object"==typeof module?("undefined"==typeof window.jQuery&&(window.jQuery=require("jquery")),module.exports=a(require("react"),require("react-dom"),window.jQuery,require("signalr"))):a(React,ReactDOM,jQuery)}(function(a,b,c){function d(a,b,d,e,f){this.$vmId=a,this.$component=b,this.$vmArg=f,this.$requested=!1,this.$loaded=!1,this.$itemKey={},"function"!=typeof d&&(this.$vmArg=d,d=function(){return b.state},e=function(a){b.setState(a)}),b.props.hasOwnProperty("vmArg")&&(this.$vmArg=c.extend(this.$vmArg,b.props.vmArg)),this.State=function(a){return"undefined"==typeof a?d():e(a)};for(var g in dotnetify.react.plugins){var h=dotnetify.react.plugins[g];h.hasOwnProperty("$inject")&&h.$inject(this)}}return function(a,b,c){"use strict";function d(b,c){return function(){c.apply(b,a.makeArray(arguments))}}function e(b,c){var e,f,g,h,i;for(e in b)if(b.hasOwnProperty(e)){if(f=b[e],!f.hubName)continue;i=c?f.on:f.off;for(g in f.client)if(f.client.hasOwnProperty(g)){if(h=f.client[g],!a.isFunction(h))continue;i.call(f,g,d(f,h))}}}if("function"!=typeof a.signalR)throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");var f=a.signalR;a.hubConnection.prototype.createHubProxies=function(){var b={};return this.starting(function(){e(b,!0),this._registerSubscribedHubs()}).disconnected(function(){e(b,!1)}),b.dotNetifyHub=this.createHubProxy("dotNetifyHub"),b.dotNetifyHub.client={},b.dotNetifyHub.server={dispose_VM:function(c){return b.dotNetifyHub.invoke.apply(b.dotNetifyHub,a.merge(["Dispose_VM"],a.makeArray(arguments)))},request_VM:function(c,d){return b.dotNetifyHub.invoke.apply(b.dotNetifyHub,a.merge(["Request_VM"],a.makeArray(arguments)))},update_VM:function(c,d){return b.dotNetifyHub.invoke.apply(b.dotNetifyHub,a.merge(["Update_VM"],a.makeArray(arguments)))}},b},f.hub=a.hubConnection("/signalr",{useDefaultPath:!1}),a.extend(f,f.hub.createHubProxies())}(c,window),dotnetify=c.extend(dotnetify,{hub:null,hubServer:c.connection.dotNetifyHub.server,hubOptions:{transport:["webSockets","longPolling"]},debug:!0,debugFn:null,offline:!1,isOffline:!0,offlineTimeout:5e3,offlineCacheFn:null,_connectRetry:0,isConnected:function(){return c.connection.hub.state==c.signalR.connectionState.connected}}),dotnetify.react=c.extend(dotnetify.hasOwnProperty("react")?dotnetify.react:{},{version:"1.0.2-beta",viewModels:{},plugins:{},init:function(){var a=dotnetify.react,b=function(){for(var b in a.viewModels)a.viewModels[b].$requested||a.viewModels[b].$request()};if(null===dotnetify.hub){var d=c.connection.dotNetifyHub;d.client.response_VM=function(b,c){return"403"==c?void console.error("Unauthorized access to "+b):void(a.viewModels.hasOwnProperty(b)?a.viewModels[b].$update(c):d.server.dispose_VM(b))};var e=function(){var a="undefined"==typeof dotnetify.hubOptions?c.connection.hub.start():c.connection.hub.start(dotnetify.hubOptions);return a.done(function(){dotnetify._connectRetry=0,b()}).fail(function(a){console.error(a)}),setTimeout(function(){dotnetify.offline&&!dotnetify.isConnected()&&(b(),dotnetify.isOffline=!0,c(document).trigger("offline",dotnetify.isOffline))},dotnetify.offlineTimeout),a};dotnetify.hub=e(),c.connection.hub.disconnected(function(){setTimeout(function(){dotnetify.hub=e()},5e3*dotnetify._connectRetry+500),dotnetify._connectRetry<3&&dotnetify._connectRetry++}),c.connection.hub.stateChanged(function(a){var b={0:"connecting",1:"connected",2:"reconnecting",4:"disconnected"};console.log("SignalR: "+b[a.newState]);var d=1!=a.newState;dotnetify.isOffline!=d&&(dotnetify.isOffline=d,c(document).trigger("offline",dotnetify.isOffline))})}else dotnetify.isConnected()?dotnetify.hub.done(b):dotnetify.offline&&b()},connect:function(a,b,c,e,f){if(dotnetify.ssr)return dotnetify.react.ssrConnect(a,b,f);var g=dotnetify.react;return g.viewModels.hasOwnProperty(a)?console.error("Component is attempting to connect to an already active '"+a+"'. If it's from a dismounted component, you must add vm.$destroy to componentWillUnmount()."):g.viewModels[a]=new d(a,b,c,e,f),g.init(),g.viewModels[a]},ssrConnect:function(a,b,e){null!=window.ssr&&window.ssr.hasOwnProperty(a)||console.error("Server-side rendering requires initial state in 'window.ssr."+a+"'.");var f=dotnetify.react,g=window.ssr[a],h=function(){return g},i=function(a){g=c.extend(g,a)},j=f.viewModels[a]=new d(a,b,h,i,e);return setTimeout(function(){j.$update(JSON.stringify(window.ssr[a]))},100),j}}),d.prototype.$destroy=function(){for(var a in dotnetify.react.plugins){var b=dotnetify.react.plugins[a];"function"==typeof b.$destroy&&b.$destroy.apply(this)}dotnetify.hubServer.dispose_VM(this.$vmId),delete dotnetify.react.viewModels[this.$vmId]},d.prototype.$dispatch=function(a){if(dotnetify.isConnected())try{dotnetify.hubServer.update_VM(this.$vmId,a),dotnetify.debug&&(console.log("["+this.$vmId+"] sent> "),console.log(a),null!=dotnetify.debugFn&&dotnetify.debugFn(this.$vmId,"sent",a))}catch(a){console.error(a)}},d.prototype.$dispatchListState=function(a){for(var b in a){var c=this.$itemKey[b];if(!c)return void console.error("["+this.$vmId+"] missing item key for '"+b+"'; add "+b+"_itemKey property to the view model.");var d=a[b];if(!d[c])return console.error("["+this.$vmId+"] couldn't dispatch data from '"+b+"' due to missing property '"+c+"'"),void console.error(d);for(var e in d)if(e!=c){var f={};f[b+".$"+d[c]+"."+e]=d[e],this.$dispatch(f)}this.$updateList(b,d)}},d.prototype.$loadHtmlView=function(a,d,e,f,g){var h=this;try{b.unmountComponentAtNode(document.querySelector(a))}catch(a){console.error(a)}c(a).load(d,null,function(){null!=e?c.getScript(e,function(){"function"==typeof g&&g.call(h)}):"function"==typeof g&&g.call(h)})},d.prototype.$loadReactView=function(d,e,f,g,h,i){var j=this,k=function(){if(!window.hasOwnProperty(e))return void console.error("["+j.$vmId+"] failed to load view '"+e+"' because it's not a React element.");try{var c=a.createElement(window[e],h);b.render(c,document.querySelector(d))}catch(a){console.error(a)}"function"==typeof i&&i.call(j,c)};if(null==f)k();else{var l=f.split(",").map(function(a){return c.getScript(a)});l.push(c.Deferred(function(a){c(a.resolve)})),c.when.apply(c,l).done(k)}},d.prototype.$preProcess=function(a){var b=this;for(var c in a){var d=/(.*)_add/.exec(c);if(null==d){var d=/(.*)_update/.exec(c);if(null==d){var d=/(.*)_remove/.exec(c);if(null==d){var d=/(.*)_itemKey/.exec(c);if(null==d);else{var e=d[1],f={};f[e]=a[c],b.$setItemKey(f),delete a[c]}}else{var e=d[1];if(Array.isArray(this.State()[e])){var g=this.$itemKey[e];null!=g?b.$removeList(e,function(b){return b[g]==a[c]}):console.error("["+this.$vmId+"] missing item key for '"+e+"'; add "+e+"_itemKey property to the view model.")}else console.error("["+this.$vmId+"] '"+e+"' is not found or not an array.");delete a[c]}}else{var e=d[1];Array.isArray(this.State()[e])?b.$updateList(e,a[c]):console.error("["+this.$vmId+"] '"+e+"' is not found or not an array."),delete a[c]}}else{var e=d[1];Array.isArray(this.State()[e])?b.$addList(e,a[c]):console.error("unable to resolve "+c),delete a[c]}}},d.prototype.$request=function(){dotnetify.isConnected()&&(dotnetify.hubServer.request_VM(this.$vmId,this.$vmArg),this.$requested=!0)},d.prototype.$update=function(a){dotnetify.debug&&(console.log("["+this.$vmId+"] received> "),console.log(JSON.parse(a)),null!=dotnetify.debugFn&&dotnetify.debugFn(this.$vmId,"received",JSON.parse(a)));var b=JSON.parse(a);this.$preProcess(b);var d=this.State();d=c.extend(d,b),this.State(d),this.$loaded||this.$onLoad()},d.prototype.$onLoad=function(){for(var a in dotnetify.react.plugins){var b=dotnetify.react.plugins[a];"function"==typeof b.$ready&&b.$ready.apply(this)}this.$loaded=!0},d.prototype.$setItemKey=function(a){this.$itemKey=a},d.prototype.$addList=function(a,b){var c=this.$itemKey[a];if(null!=c){if(!b.hasOwnProperty(c))return void console.error("["+this.$vmId+"] couldn't add item to '"+a+"' due to missing property '"+c+"'");var d=this.State()[a].filter(function(a){return a[c]==b[c]});if(d.length>0)return void console.error("["+this.$vmId+"] couldn't add item to '"+listName+"' because the key already exists")}var e=this.State()[a];e.push(b);var f={};f[a]=e,this.State(f)},d.prototype.$removeList=function(a,b){var c={};c[a]=this.State()[a].filter(function(a){return!b(a)}),this.State(c)},d.prototype.$updateList=function(a,b){var d=this.$itemKey[a];if(null!=d){if(!b.hasOwnProperty(d))return void console.error("["+this.$vmId+"] couldn't update item to '"+a+"' due to missing property '"+d+"'");var e={};e[a]=this.State()[a].map(function(a){return a[d]==b[d]?c.extend(a,b):a}),this.State(e)}else console.error("["+this.$vmId+"] missing item key for '"+listName+"'; add "+listName+"_itemKey property to the view model.")},dotnetify.react.Scope=a.createClass({displayName:"Scope",propTypes:{vm:a.PropTypes.string},contextTypes:{scoped:a.PropTypes.func},childContextTypes:{scoped:a.PropTypes.func.isRequired,connect:a.PropTypes.func.isRequired},scoped:function(a){var b=this.context.scoped?this.context.scoped(this.props.vm):this.props.vm;return b?b+"."+a:a},getChildContext:function(){var a=this;return{scoped:function(b){return a.scoped(b)},connect:function(b,c,d,e,f){var g="function"==typeof d?d:function(){return c.state},h="function"==typeof e?e:function(a){return c.setState(a)};return"function"!=typeof d&&(f=d),c.vmId=a.scoped(b),c.vm=dotnetify.react.connect(c.vmId,c,g,h,f),c.dispatch=function(a){return c.vm.$dispatch(a)},c.dispatchState=function(a){h(a),c.vm.$dispatch(a)},window.vmStates?window.vmStates[c.vmId]:null}}},render:function(){return this.props.children}}),dotnetify}); \ No newline at end of file +var dotnetify="undefined"==typeof dotnetify?{}:dotnetify;!function(a){"function"==typeof define&&define.amd?define(["react","react-dom","jquery","signalr"],a):"object"==typeof exports&&"object"==typeof module?("undefined"==typeof window.jQuery&&(window.jQuery=require("jquery")),module.exports=a(require("react"),require("react-dom"),window.jQuery,require("signalr"))):a(React,ReactDOM,jQuery)}(function(a,b,c){function d(a,b,d,e,f){this.$vmId=a,this.$component=b,this.$vmArg=f,this.$requested=!1,this.$loaded=!1,this.$itemKey={},"function"!=typeof d&&(this.$vmArg=d,d=function(){return b.state},e=function(a){b.setState(a)}),b.props.hasOwnProperty("vmArg")&&(this.$vmArg=c.extend(this.$vmArg,b.props.vmArg)),this.State=function(a){return"undefined"==typeof a?d():e(a)};for(var g in dotnetify.react.plugins){var h=dotnetify.react.plugins[g];h.hasOwnProperty("$inject")&&h.$inject(this)}}return function(a,b,c){"use strict";function d(b,c){return function(){c.apply(b,a.makeArray(arguments))}}function e(b,c){var e,f,g,h,i;for(e in b)if(b.hasOwnProperty(e)){if(f=b[e],!f.hubName)continue;i=c?f.on:f.off;for(g in f.client)if(f.client.hasOwnProperty(g)){if(h=f.client[g],!a.isFunction(h))continue;i.call(f,g,d(f,h))}}}if("function"!=typeof a.signalR)throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");var f=a.signalR;a.hubConnection.prototype.createHubProxies=function(){var b={};return this.starting(function(){e(b,!0),this._registerSubscribedHubs()}).disconnected(function(){e(b,!1)}),b.dotNetifyHub=this.createHubProxy("dotNetifyHub"),b.dotNetifyHub.client={},b.dotNetifyHub.server={dispose_VM:function(c){return b.dotNetifyHub.invoke.apply(b.dotNetifyHub,a.merge(["Dispose_VM"],a.makeArray(arguments)))},request_VM:function(c,d){return b.dotNetifyHub.invoke.apply(b.dotNetifyHub,a.merge(["Request_VM"],a.makeArray(arguments)))},update_VM:function(c,d){return b.dotNetifyHub.invoke.apply(b.dotNetifyHub,a.merge(["Update_VM"],a.makeArray(arguments)))}},b},f.hub=a.hubConnection("/signalr",{useDefaultPath:!1}),a.extend(f,f.hub.createHubProxies())}(c,window),dotnetify=c.extend(dotnetify,{hub:null,hubServer:c.connection.dotNetifyHub.server,hubOptions:{transport:["webSockets","longPolling"]},debug:!0,debugFn:null,offline:!1,isOffline:!0,offlineTimeout:5e3,offlineCacheFn:null,_connectRetry:0,isConnected:function(){return c.connection.hub.state==c.signalR.connectionState.connected}}),dotnetify.react=c.extend(dotnetify.hasOwnProperty("react")?dotnetify.react:{},{version:"1.0.3-beta",viewModels:{},plugins:{},init:function(){var a=dotnetify.react,b=function(){for(var b in a.viewModels)a.viewModels[b].$requested||a.viewModels[b].$request()};if(null===dotnetify.hub){var d=c.connection.dotNetifyHub;d.client.response_VM=function(b,c){return"403"==c?void console.error("Unauthorized access to "+b):void(a.viewModels.hasOwnProperty(b)?a.viewModels[b].$update(c):d.server.dispose_VM(b))};var e=function(){var a="undefined"==typeof dotnetify.hubOptions?c.connection.hub.start():c.connection.hub.start(dotnetify.hubOptions);return a.done(function(){dotnetify._connectRetry=0,b()}).fail(function(a){console.error(a)}),setTimeout(function(){dotnetify.offline&&!dotnetify.isConnected()&&(b(),dotnetify.isOffline=!0,c(document).trigger("offline",dotnetify.isOffline))},dotnetify.offlineTimeout),a};dotnetify.hub=e(),c.connection.hub.disconnected(function(){setTimeout(function(){dotnetify.hub=e()},5e3*dotnetify._connectRetry+500),dotnetify._connectRetry<3&&dotnetify._connectRetry++}),c.connection.hub.stateChanged(function(a){var b={0:"connecting",1:"connected",2:"reconnecting",4:"disconnected"};console.log("SignalR: "+b[a.newState]);var d=1!=a.newState;dotnetify.isOffline!=d&&(dotnetify.isOffline=d,c(document).trigger("offline",dotnetify.isOffline))})}else dotnetify.isConnected()?dotnetify.hub.done(b):dotnetify.offline&&b()},connect:function(a,b,c,e,f){if(dotnetify.ssr)return dotnetify.react.ssrConnect(a,b,f);var g=dotnetify.react;return g.viewModels.hasOwnProperty(a)?console.error("Component is attempting to connect to an already active '"+a+"'. If it's from a dismounted component, you must add vm.$destroy to componentWillUnmount()."):g.viewModels[a]=new d(a,b,c,e,f),g.init(),g.viewModels[a]},ssrConnect:function(a,b,e){null!=window.ssr&&window.ssr.hasOwnProperty(a)||console.error("Server-side rendering requires initial state in 'window.ssr."+a+"'.");var f=dotnetify.react,g=window.ssr[a],h=function(){return g},i=function(a){g=c.extend(g,a)},j=f.viewModels[a]=new d(a,b,h,i,e);return setTimeout(function(){j.$update(JSON.stringify(window.ssr[a]))},100),j}}),d.prototype.$destroy=function(){for(var a in dotnetify.react.plugins){var b=dotnetify.react.plugins[a];"function"==typeof b.$destroy&&b.$destroy.apply(this)}dotnetify.hubServer.dispose_VM(this.$vmId),delete dotnetify.react.viewModels[this.$vmId]},d.prototype.$dispatch=function(a){if(dotnetify.isConnected())try{dotnetify.hubServer.update_VM(this.$vmId,a),dotnetify.debug&&(console.log("["+this.$vmId+"] sent> "),console.log(a),null!=dotnetify.debugFn&&dotnetify.debugFn(this.$vmId,"sent",a))}catch(a){console.error(a)}},d.prototype.$dispatchListState=function(a){for(var b in a){var c=this.$itemKey[b];if(!c)return void console.error("["+this.$vmId+"] missing item key for '"+b+"'; add "+b+"_itemKey property to the view model.");var d=a[b];if(!d[c])return console.error("["+this.$vmId+"] couldn't dispatch data from '"+b+"' due to missing property '"+c+"'"),void console.error(d);for(var e in d)if(e!=c){var f={};f[b+".$"+d[c]+"."+e]=d[e],this.$dispatch(f)}this.$updateList(b,d)}},d.prototype.$loadHtmlView=function(a,d,e,f,g){var h=this;try{b.unmountComponentAtNode(document.querySelector(a))}catch(a){console.error(a)}c(a).load(d,null,function(){null!=e?c.getScript(e,function(){"function"==typeof g&&g.call(h)}):"function"==typeof g&&g.call(h)})},d.prototype.$loadReactView=function(d,e,f,g,h,i){var j=this,k=function(){if(!window.hasOwnProperty(e))return void console.error("["+j.$vmId+"] failed to load view '"+e+"' because it's not a React element.");try{b.unmountComponentAtNode(document.querySelector(d))}catch(a){console.error(a)}try{var c=a.createElement(window[e],h);b.render(c,document.querySelector(d))}catch(a){console.error(a)}"function"==typeof i&&i.call(j,c)};if(null==f)k();else{var l=f.split(",").map(function(a){return c.getScript(a)});l.push(c.Deferred(function(a){c(a.resolve)})),c.when.apply(c,l).done(k)}},d.prototype.$preProcess=function(a){var b=this;for(var c in a){var d=/(.*)_add/.exec(c);if(null==d){var d=/(.*)_update/.exec(c);if(null==d){var d=/(.*)_remove/.exec(c);if(null==d){var d=/(.*)_itemKey/.exec(c);if(null==d);else{var e=d[1],f={};f[e]=a[c],b.$setItemKey(f),delete a[c]}}else{var e=d[1];if(Array.isArray(this.State()[e])){var g=this.$itemKey[e];null!=g?b.$removeList(e,function(b){return b[g]==a[c]}):console.error("["+this.$vmId+"] missing item key for '"+e+"'; add "+e+"_itemKey property to the view model.")}else console.error("["+this.$vmId+"] '"+e+"' is not found or not an array.");delete a[c]}}else{var e=d[1];Array.isArray(this.State()[e])?b.$updateList(e,a[c]):console.error("["+this.$vmId+"] '"+e+"' is not found or not an array."),delete a[c]}}else{var e=d[1];Array.isArray(this.State()[e])?b.$addList(e,a[c]):console.error("unable to resolve "+c),delete a[c]}}},d.prototype.$request=function(){dotnetify.isConnected()&&(dotnetify.hubServer.request_VM(this.$vmId,this.$vmArg),this.$requested=!0)},d.prototype.$update=function(a){dotnetify.debug&&(console.log("["+this.$vmId+"] received> "),console.log(JSON.parse(a)),null!=dotnetify.debugFn&&dotnetify.debugFn(this.$vmId,"received",JSON.parse(a)));var b=JSON.parse(a);this.$preProcess(b);var d=this.State();d=c.extend(d,b),this.State(d),this.$loaded||this.$onLoad()},d.prototype.$onLoad=function(){for(var a in dotnetify.react.plugins){var b=dotnetify.react.plugins[a];"function"==typeof b.$ready&&b.$ready.apply(this)}this.$loaded=!0},d.prototype.$setItemKey=function(a){this.$itemKey=a},d.prototype.$addList=function(a,b){var c=this.$itemKey[a];if(null!=c){if(!b.hasOwnProperty(c))return void console.error("["+this.$vmId+"] couldn't add item to '"+a+"' due to missing property '"+c+"'");var d=this.State()[a].filter(function(a){return a[c]==b[c]});if(d.length>0)return void console.error("["+this.$vmId+"] couldn't add item to '"+listName+"' because the key already exists")}var e=this.State()[a];e.push(b);var f={};f[a]=e,this.State(f)},d.prototype.$removeList=function(a,b){var c={};c[a]=this.State()[a].filter(function(a){return!b(a)}),this.State(c)},d.prototype.$updateList=function(a,b){var d=this.$itemKey[a];if(null!=d){if(!b.hasOwnProperty(d))return void console.error("["+this.$vmId+"] couldn't update item to '"+a+"' due to missing property '"+d+"'");var e={};e[a]=this.State()[a].map(function(a){return a[d]==b[d]?c.extend(a,b):a}),this.State(e)}else console.error("["+this.$vmId+"] missing item key for '"+listName+"'; add "+listName+"_itemKey property to the view model.")},dotnetify.react.Scope=a.createClass({displayName:"Scope",propTypes:{vm:a.PropTypes.string},contextTypes:{scoped:a.PropTypes.func},childContextTypes:{scoped:a.PropTypes.func.isRequired,connect:a.PropTypes.func.isRequired},scoped:function(a){var b=this.context.scoped?this.context.scoped(this.props.vm):this.props.vm;return b?b+"."+a:a},getChildContext:function(){var a=this;return{scoped:function(b){return a.scoped(b)},connect:function(b,c,d,e,f){var g="function"==typeof d?d:function(){return c.state},h="function"==typeof e?e:function(a){return c.setState(a)};return"function"!=typeof d&&(f=d),c.vmId=a.scoped(b),c.vm=dotnetify.react.connect(c.vmId,c,g,h,f),c.dispatch=function(a){return c.vm.$dispatch(a)},c.dispatchState=function(a){h(a),c.vm.$dispatch(a)},window.vmStates?window.vmStates[c.vmId]:null}}},render:function(){return this.props.children}}),dotnetify}); \ No newline at end of file diff --git a/package.json b/package.json index 577de2e5..d0603187 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dotnetify", - "version": "2.0.4-beta", + "version": "2.0.5-beta", "description": "Simple, lightweight, yet powerful way to build realtime .NET web apps.", "main": "dist/dotnetify-react.js", "files": [