forked from ngReact/ngReact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ngReact.min.js
1 lines (1 loc) · 1.91 KB
/
ngReact.min.js
1
(function(n,t){t["true"]=n,function(n,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("react"),require("angular")):"function"==typeof define&&define.amd?define(["react","angular"],function(e,angular){return n.ngReact=t(e,angular)}):n.ngReact=t(n.React,n.angular)}(this,function(React,angular){"use strict";function n(n,t){if(angular.isFunction(n))return n;if(!n)throw Error("ReactComponent name attribute must be specified");var e;try{e=t.get(n)}catch(r){}if(!e)try{e=n.split(".").reduce(function(n,t){return n[t]},window)}catch(r){}if(!e)throw Error("Cannot find react component "+n);return e}function t(n,t){return n.wrappedInApply?n:function(){var e=arguments;t.$apply(function(){n.wrappedInApply=!0,n.apply(null,e)})}}function e(n,e){return Object.keys(n||{}).reduce(function(r,o){var c=n[o];return r[o]=angular.isFunction(c)?t(c,e):c,r},{})}function r(n,t){var e,r=Array.prototype.slice.call(arguments,2);"collection"===n&&angular.isFunction(t.$watchCollection)?e="$watchCollection":(e="$watch","reference"!==n&&r.push(!0)),t[e].apply(t,r)}function o(n,t,e,r){e(function(){React.render(React.createElement(n,t),r[0])})}var c=function(t,c){return{restrict:"E",replace:!0,link:function(i,u,a){var f=n(a.name,c),p=function(){var n=i.$eval(a.props),r=e(n,i);o(f,r,t,u)};a.props?r(a.watchDepth,i,a.props,p):p(),i.$on("$destroy",function(){React.unmountComponentAtNode(u[0])})}}},i=function(t,c){return function(i,u,a){var f={restrict:"E",replace:!0,link:function(a,f,p){var l=n(i,c);u=u||Object.keys(l.propTypes||{});var s=function(){var n={};u.forEach(function(t){n[t]=a.$eval(p[t])}),o(l,e(n,a),t,f)};u.forEach(function(n){r(p.watchDepth,a,p[n],s)}),s(),a.$on("$destroy",function(){React.unmountComponentAtNode(f[0])})}};return angular.extend(f,a)}};return angular.module("react",[]).directive("reactComponent",["$timeout","$injector",c]).factory("reactDirective",["$timeout","$injector",i])})})({},function(){return this}());