throw deprecation error for @jsx React.DOM usage and crawl all comments for pragmas - fixes #876

This commit is contained in:
Sebastian McKenzie 2015-02-24 09:38:16 +11:00
parent ae8b1e242b
commit f2eb1643c0
2 changed files with 11 additions and 2 deletions

View File

@ -54,6 +54,7 @@ module.exports = function (exports, opts) {
return t.inherits(t.property("init", node.name, value), node);
}
};
exports.JSXOpeningElement = {
exit: function (node, parent, scope, file) {
var tagExpr = node.name;

View File

@ -9,9 +9,17 @@ exports.Program = function (node, parent, scope, file) {
var id = "React.createElement";
var comment = file.ast.comments[0];
if (comment) {
for (var i = 0; i < file.ast.comments.length; i++) {
var comment = file.ast.comments[i];
var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
if (matches) id = matches[1];
if (matches) {
id = matches[1];
if (id === "React.DOM") {
throw file.errorWithNode(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
} else {
break;
}
}
}
file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {