throw deprecation error for @jsx React.DOM usage and crawl all comments for pragmas - fixes #876
This commit is contained in:
parent
ae8b1e242b
commit
f2eb1643c0
@ -54,6 +54,7 @@ module.exports = function (exports, opts) {
|
|||||||
return t.inherits(t.property("init", node.name, value), node);
|
return t.inherits(t.property("init", node.name, value), node);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.JSXOpeningElement = {
|
exports.JSXOpeningElement = {
|
||||||
exit: function (node, parent, scope, file) {
|
exit: function (node, parent, scope, file) {
|
||||||
var tagExpr = node.name;
|
var tagExpr = node.name;
|
||||||
|
|||||||
@ -9,9 +9,17 @@ exports.Program = function (node, parent, scope, file) {
|
|||||||
var id = "React.createElement";
|
var id = "React.createElement";
|
||||||
|
|
||||||
var comment = file.ast.comments[0];
|
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);
|
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) {
|
file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user