Skip to content

Commit

Permalink
prep JSX transpile target for unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdan committed Jul 23, 2015
1 parent eebe436 commit 28209fd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions element.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
/**
* A function used by Babel to transpile JSX code into jQuery elements
*/
let $ = require("jquery");

function buildElement(type, props, ...children) {
// We need to require jQuery inside of this method because `require()`
// will work different after mocha's magic "before" method runs.
//
// This allows us to use the jQuery instance provided by our jsdom
// instance.
let $ = require("jquery");

// Is our element a TextNode?
if (props === undefined) {
// Type will be the text content, which can simply be returned here
return type;
}

// Create a jQuery element
let $el = $(document.createElement(type));
let $el = $("<" + type + ">");

// Iterate through props
if (props !== null) {
Expand Down

0 comments on commit 28209fd

Please sign in to comment.