Sha256: cd615067f53008579a8ac872adea770ab4fff7948930c6998319a5332238b0f8

Contents?: true

Size: 1.87 KB

Versions: 8

Compression:

Stored size: 1.87 KB

Contents

"use strict";

exports.__esModule = true;
// istanbul ignore next

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }

var _helpersReact = require("../../helpers/react");

var react = _interopRequireWildcard(_helpersReact);

var _types = require("../../../types");

var t = _interopRequireWildcard(_types);

/**
 * [Please add a description.]
 */

var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;

var metadata = {
  group: "builtin-advanced"
};

exports.metadata = metadata;
/**
 * [Please add a description.]
 */

var visitor = require("../../helpers/build-react-transformer")({

  /**
   * [Please add a description.]
   */

  pre: function pre(state) {
    var tagName = state.tagName;
    var args = state.args;
    if (react.isCompatTag(tagName)) {
      args.push(t.literal(tagName));
    } else {
      args.push(state.tagExpr);
    }
  },

  /**
   * [Please add a description.]
   */

  post: function post(state, file) {
    state.callee = file.get("jsxIdentifier");
  }
});

exports.visitor = visitor;
/**
 * [Please add a description.]
 */

visitor.Program = function (node, parent, scope, file) {
  var id = file.opts.jsxPragma;

  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 (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) {
    return t.memberExpression(object, property);
  }));
};

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
ilog-0.4.1 node_modules/babel/node_modules/babel-core/lib/transformation/transformers/other/react.js
ilog-0.4.0 node_modules/babel/node_modules/babel-core/lib/transformation/transformers/other/react.js
ilog-0.3.3 node_modules/babel/node_modules/babel-core/lib/transformation/transformers/other/react.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/babel-core/lib/transformation/transformers/other/react.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/babel-core/lib/transformation/transformers/other/react.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/babel-core/lib/transformation/transformers/other/react.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/babel-core/lib/transformation/transformers/other/react.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/babel-core/lib/transformation/transformers/other/react.js