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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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;
};
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use strict";

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

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

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

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

({
$$typeof: babelHelpers.typeofReactElement,
type: Foo,
ref: null,
props: babelHelpers.defaultProps(Foo.defaultProps, {}),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use strict";

({
$$typeof: babelHelpers.typeofReactElement,
type: "div",
ref: null,
props: {
children: bar,
className: "foo"
},
key: null
});
});
Original file line number Diff line number Diff line change
@@ -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
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

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

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

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

({
$$typeof: babelHelpers.typeofReactElement,
type: "foo",
ref: null,
props: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -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.