diff --git a/lib/babel/transformation/helpers/build-react-transformer.js b/lib/babel/transformation/helpers/build-react-transformer.js index 3076873888..7506a305a8 100644 --- a/lib/babel/transformation/helpers/build-react-transformer.js +++ b/lib/babel/transformation/helpers/build-react-transformer.js @@ -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; diff --git a/lib/babel/transformation/transformers/other/react.js b/lib/babel/transformation/transformers/other/react.js index b8d7a727fb..8473f33270 100644 --- a/lib/babel/transformation/transformers/other/react.js +++ b/lib/babel/transformation/transformers/other/react.js @@ -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) {