Created
February 8, 2015 04:01
-
-
Save mrmurphy/8da6a57e5a0ad83492ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Changes `class=` to `className=` and 'for=' to `htmlFor=` | |
* for the sake of JSX! | |
*/ | |
if (typeof module === 'object' && typeof define !== 'function') { | |
var define = function (factory) { | |
module.exports = factory(require, exports, module); | |
}; | |
} | |
define(function(require, exports, module) { | |
var tokenMap = { | |
'class=': 'className=', | |
'for=': 'htmlFor=' | |
}; | |
function replaceTokens(str) { | |
// Object.keys(tokenMap).forEach(function(k){ | |
// str = str.replace(k, tokenMap[k]); | |
// }) | |
// return str | |
return 'foo' | |
} | |
return function process(tree) { | |
tree.children.forEach(function(item) { | |
item.start = replaceTokens(item.start); | |
item.end = replaceTokens(item.end); | |
item.content = replaceTokens(item.content); | |
process(item); | |
}); | |
return tree; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment