Skip to content

Commit

Permalink
Include $$typeof on inlined React elements
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebits committed Sep 10, 2015
1 parent 436ba9b commit 1d0e68f
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/babel/src/transformation/file/index.js
Expand Up @@ -92,6 +92,7 @@ export default class File {
"temporal-undefined",
"temporal-assert-defined",
"self-global",
"typeof-react-element",
"default-props",
"instanceof",

Expand Down
@@ -0,0 +1 @@
(typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7
Expand Up @@ -61,6 +61,7 @@ export var visitor = {
}

// metadata
pushElemProp("$$typeof", file.addHelper("typeof-react-element"));
pushElemProp("type", type);
pushElemProp("ref", t.literal(null));

Expand Down
@@ -1,6 +1,9 @@
"use strict";

var _typeofReactElement = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 60103;

var _ref = {
$$typeof: _typeofReactElement,
type: "foo",
ref: null,
props: {},
Expand All @@ -13,6 +16,7 @@ function render() {
function render() {
var text = getText();
var _ref2 = {
$$typeof: _typeofReactElement,
type: "foo",
ref: null,
props: {
Expand All @@ -23,4 +27,4 @@ function render() {
return function () {
return _ref2;
};
}
}
@@ -1,10 +1,11 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Baz,
ref: null,
props: babelHelpers.defaultProps(Baz.defaultProps, {
foo: "bar"
}),
key: null
});
});
@@ -1,8 +1,9 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Baz,
ref: null,
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
key: null
});
});
@@ -1,10 +1,11 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "foo",
ref: null,
props: {
bar: "foo"
},
key: null
});
});
@@ -1,8 +1,9 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "foo",
ref: null,
props: {},
key: null
});
});
@@ -1,6 +1,7 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Foo,
ref: null,
props: babelHelpers.defaultProps(Foo.defaultProps, {}),
Expand Down
@@ -1,10 +1,12 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Foo,
ref: null,
props: babelHelpers.defaultProps(Foo.defaultProps, {
children: [bar, {
$$typeof: babelHelpers.typeofReactElement,
type: Baz,
ref: null,
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
Expand All @@ -13,4 +15,4 @@
className: "foo"
}),
key: null
});
});
@@ -1,11 +1,12 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "div",
ref: null,
props: {
children: bar,
className: "foo"
},
key: null
});
});
@@ -1,10 +1,12 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "div",
ref: null,
props: {
children: [bar, {
$$typeof: babelHelpers.typeofReactElement,
type: Baz,
ref: null,
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
Expand All @@ -13,4 +15,4 @@
className: "foo"
},
key: null
});
});
@@ -1,6 +1,7 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Baz,
ref: null,
props: babelHelpers.defaultProps(Baz.defaultProps, {
Expand Down
@@ -1,6 +1,7 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Baz,
ref: null,
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
Expand Down
@@ -1,6 +1,7 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "foo",
ref: null,
props: {
Expand Down
@@ -1,6 +1,7 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "foo",
ref: null,
props: {},
Expand Down
@@ -1,10 +1,11 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: Foo,
ref: null,
props: babelHelpers.defaultProps(Foo.defaultProps, {
bar: true
}),
key: null
});
});

0 comments on commit 1d0e68f

Please sign in to comment.