Merge pull request #1108 from ArrestedDevelopment/jsxpragma-option

JSX Transformer: Add 'jsxPragma' option
This commit is contained in:
Sebastian McKenzie 2015-03-28 22:17:18 +11:00
commit b54901018b
8 changed files with 54 additions and 1 deletions

View File

@ -83,6 +83,13 @@
"shorthand": "L"
},
"jsxPragma": {
"type": "string",
"description": "Custom pragma to use with JSX (same functionality as @jsx comments)",
"default": "React.createElement",
"shorthand": "P"
},
"ignore": {
"type": "list"
},

View File

@ -4,7 +4,7 @@ import * as t from "../../../types";
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
export function Program(node, parent, scope, file) {
var id = "React.createElement";
var id = file.opts.jsxPragma;
for (var i = 0; i < file.ast.comments.length; i++) {
var comment = file.ast.comments[i];

View File

@ -0,0 +1,8 @@
/** @jsx dom */
<Foo></Foo>;
var profile = <div>
<img src="avatar.png" className="profile" />
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
</div>;

View File

@ -0,0 +1,14 @@
/** @jsx dom */
dom(Foo, null);
var profile = dom(
"div",
null,
dom("img", { src: "avatar.png", className: "profile" }),
dom(
"h3",
null,
[user.firstName, user.lastName].join(" ")
)
);

View File

@ -0,0 +1,3 @@
{
"jsxPragma": "foo.bar"
}

View File

@ -0,0 +1,6 @@
<Foo></Foo>;
var profile = <div>
<img src="avatar.png" className="profile" />
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
</div>;

View File

@ -0,0 +1,12 @@
dom(Foo, null);
var profile = dom(
"div",
null,
dom("img", { src: "avatar.png", className: "profile" }),
dom(
"h3",
null,
[user.firstName, user.lastName].join(" ")
)
);

View File

@ -0,0 +1,3 @@
{
"jsxPragma": "dom"
}