File tree Expand file tree Collapse file tree 5 files changed +4593
-3
lines changed
Expand file tree Collapse file tree 5 files changed +4593
-3
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ window.reactR = (function () {
1414 var elem = components . hasOwnProperty ( tag . name ) ? components [ tag . name ] : tag . name ,
1515 args = [ elem , tag . attribs ] ;
1616 for ( var i = 0 ; i < tag . children . length ; i ++ ) {
17- if ( typeof tag . children [ i ] === 'string' ) {
18- args . push ( tag . children [ i ] ) ;
19- } else {
17+ if ( typeof tag . children [ i ] === 'object' ) {
2018 args . push ( hydrate ( components , tag . children [ i ] ) ) ;
19+ } else {
20+ args . push ( tag . children [ i ] ) ;
2121 }
2222 }
2323 return React . createElement . apply ( null , args ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ describe ( 'window.reactR' , ( ) => {
4+ describe ( '#hydrate()' , ( ) => {
5+ it ( 'should throw an exception with an unknown component' , ( ) => {
6+ assert . throws ( ( ) => {
7+ reactR . hydrate (
8+ {
9+ Foo : class Foo extends React . Component {
10+ render ( ) {
11+ return < h1 > Foo!</ h1 > ;
12+ }
13+ }
14+ } ,
15+ {
16+ name : "Bar" ,
17+ attribs : { } ,
18+ children : { }
19+ }
20+ )
21+ } , Error , / U n k n o w n c o m p o n e n t / ) ;
22+ } ) ;
23+ } ) ;
24+ } ) ;
Original file line number Diff line number Diff line change 1+ // TODO: Get source maps for failures working.
2+ module . exports = function ( config ) {
3+ config . set ( {
4+ frameworks : [ 'mocha' , 'chai' ] ,
5+ files : [ 'inst/www/react-tools/react-tools.js' , 'js-tests/js-tests.jsx' ] ,
6+ preprocessors : {
7+ 'js-tests/*.js' : [ 'webpack' ] ,
8+ 'js-tests/*.jsx' : [ 'webpack' , 'sourcemap' ]
9+ } ,
10+ webpack : {
11+ module : {
12+ rules : [
13+ {
14+ test : [ / \. j s $ / , / \. j s x $ / ] ,
15+ loader : 'babel-loader' ,
16+ options : {
17+ presets : [ '@babel/preset-env' , '@babel/preset-react' ]
18+ }
19+ }
20+ ]
21+ } ,
22+ devtool : 'source-map'
23+ } ,
24+ webpackMiddleware : {
25+ stats : 'errors-only'
26+ } ,
27+ reporters : [ 'progress' ] ,
28+ port : 9876 , // karma web server port
29+ colors : true ,
30+ logLevel : config . LOG_INFO ,
31+ browsers : [ 'ChromeHeadless' ] ,
32+ autoWatch : false ,
33+ // singleRun: false, // Karma captures browsers, runs the tests and exits
34+ concurrency : Infinity
35+ } )
36+ }
Original file line number Diff line number Diff line change 1+ {
2+ "devDependencies" : {
3+ "chai" : " ^4.2.0" ,
4+ "karma" : " ^3.1.4" ,
5+ "karma-chai" : " ^0.1.0" ,
6+ "karma-chrome-launcher" : " ^2.2.0" ,
7+ "karma-mocha" : " ^1.3.0" ,
8+ "karma-webpack" : " ^3.0.5" ,
9+ "karma-sourcemap-loader" : " ^0.3.7" ,
10+ "mocha" : " ^5.2.0" ,
11+ "react" : " ^16.7.0" ,
12+ "react-dom" : " ^16.7.0" ,
13+ "webpack" : " ^3.0.0" ,
14+ "@babel/core" : " ^7.2.0" ,
15+ "babel-loader" : " ^8.0.4" ,
16+ "@babel/preset-env" : " ^7.2.0" ,
17+ "@babel/preset-react" : " ^7.0.0"
18+ },
19+ "scripts" : {
20+ "test" : " karma start --single-run --browsers ChromeHeadless karma.conf.js"
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments