File tree Expand file tree Collapse file tree 4 files changed +14
-25
lines changed Expand file tree Collapse file tree 4 files changed +14
-25
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " react-if-comp" ,
3- "version" : " 0.0.3 " ,
3+ "version" : " 0.0.4 " ,
44 "homepage" : " https://github.com/gfdev/javascript-react-if-component" ,
55 "authors" : [
66 " Gordon Freeman <eax@gmx.us> (https://github.com/gfdev)"
1818 "license" : " MIT" ,
1919 "devDependencies" : {},
2020 "dependencies" : {
21- "react" : " ~0.14 .0"
21+ "react" : " >=0.12 .0"
2222 }
2323}
Original file line number Diff line number Diff line change 11{
22 "name" : " react-if-comp" ,
3- "version" : " 0.0.3 " ,
3+ "version" : " 0.0.4 " ,
44 "description" : " React component for conditional rendering of embedded elements or props" ,
55 "main" : " index.js" ,
66 "keywords" : [
2929 },
3030 "license" : " MIT" ,
3131 "devDependencies" : {
32- "autoprefixer-loader" : " ^3.1.0" ,
3332 "babel-core" : " ^6.3.26" ,
34- "babel-eslint" : " ^5.0.0-beta6" ,
35- "babel-loader" : " ^6.2.0" ,
3633 "babel-plugin-transform-strict-mode" : " ^6.3.13" ,
3734 "babel-preset-react" : " ^6.3.13" ,
3835 "babel-preset-stage-0" : " ^6.3.13" ,
3936 "chai" : " ^3.4.1" ,
40- "css-loader" : " ^0.23.1" ,
41- "eslint" : " ^1.10.3" ,
42- "eslint-loader" : " ^1.2.0" ,
43- "eslint-plugin-react" : " ^3.12.0" ,
44- "html-webpack-plugin" : " ^1.7.0" ,
4537 "mocha" : " ^2.3.4" ,
46- "node-sass" : " ^3.4.2" ,
47- "react-bootstrap" : " ^0.28.1" ,
48- "react-dom" : " ^0.14.0" ,
49- "react-hot-loader" : " ^1.3.0" ,
50- "sass-loader" : " ^3.1.2" ,
51- "style-loader" : " ^0.13.0" ,
52- "webpack" : " ^1.12.9" ,
53- "webpack-dev-server" : " ^1.14.0"
38+ "react-dom" : " ^0.14.0"
5439 },
5540 "dependencies" : {
56- "react" : " ^0.14 .0"
41+ "react" : " >=0.12 .0"
5742 }
5843}
Original file line number Diff line number Diff line change 11'use strict' ;
22
33var React = require ( 'react' )
4+ , version = + React . version . substring ( 0 , React . version . lastIndexOf ( '.' ) )
45 , types = [ 'bool' , 'func' , 'node' ] . map ( name => React . PropTypes [ name ] )
56;
67
@@ -12,7 +13,7 @@ function _getResult(result) {
1213 return result ;
1314
1415 if ( typeof result === 'function' ) {
15- if ( typeof result . prototype . render === 'function' )
16+ if ( result . displayName )
1617 return React . createElement ( result ) ;
1718
1819 return _getResult ( result ( ) ) ;
@@ -36,8 +37,8 @@ var IF = React.createClass({
3637
3738 if ( total ) {
3839 React . Children . forEach ( props . children , child => {
39- if ( child . type === IF ) {
40- if ( ! ( 'if' in child . props ) ) {
40+ if ( version <= 0.12 ? child . type === IF . type : child . type === IF ) {
41+ if ( child . props && ! ( 'if' in child . props ) ) {
4142 if ( props . if && child . props . then ) result . push ( child . props . children ) ;
4243 if ( ! props . if && child . props . else ) result . push ( child . props . children ) ;
4344 } else {
Original file line number Diff line number Diff line change 22
33var expect = require ( 'chai' ) . expect
44 , React = require ( 'react' )
5- , ReactDOMServer = require ( 'react-dom/server' )
5+ , version = + React . version . substring ( 0 , React . version . lastIndexOf ( '.' ) )
6+ , ReactStaticMarkup = version <= 0.13 ? React : require ( 'react-dom/server' )
67 , Node = require ( '../src/if.jsx' )
78 , nullElement = '<noscript></noscript>'
89;
@@ -24,7 +25,9 @@ var Foo = React.createClass({
2425} ) ;
2526
2627function test ( el , eq ) {
27- return expect ( ReactDOMServer . renderToStaticMarkup ( el ) ) . equal ( eq ) ;
28+ return expect (
29+ ReactStaticMarkup [ version <= 0.11 ? 'renderComponentToStaticMarkup' : 'renderToStaticMarkup' ] ( el )
30+ ) . equal ( eq ) ;
2831}
2932
3033describe ( 'React IF component testing:' , function ( ) {
You can’t perform that action at this time.
0 commit comments