Merge pull request #2352 from spicyj/jsx-xss
Include $$typeof on inlined React elements
This commit is contained in:
commit
ade747eb9c
@ -92,6 +92,7 @@ export default class File {
|
|||||||
"temporal-undefined",
|
"temporal-undefined",
|
||||||
"temporal-assert-defined",
|
"temporal-assert-defined",
|
||||||
"self-global",
|
"self-global",
|
||||||
|
"typeof-react-element",
|
||||||
"default-props",
|
"default-props",
|
||||||
"instanceof",
|
"instanceof",
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
(typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7
|
||||||
@ -60,10 +60,6 @@ export var visitor = {
|
|||||||
objProps.push(t.property("init", key, value));
|
objProps.push(t.property("init", key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// metadata
|
|
||||||
pushElemProp("type", type);
|
|
||||||
pushElemProp("ref", t.literal(null));
|
|
||||||
|
|
||||||
if (node.children.length) {
|
if (node.children.length) {
|
||||||
var children = react.buildChildren(node);
|
var children = react.buildChildren(node);
|
||||||
children = children.length === 1 ? children[0] : t.arrayExpression(children);
|
children = children.length === 1 ? children[0] : t.arrayExpression(children);
|
||||||
@ -84,10 +80,14 @@ export var visitor = {
|
|||||||
props = t.callExpression(file.addHelper("default-props"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
|
props = t.callExpression(file.addHelper("default-props"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushElemProp("props", props);
|
// metadata
|
||||||
|
pushElemProp("$$typeof", file.addHelper("typeof-react-element"));
|
||||||
// key
|
pushElemProp("type", type);
|
||||||
pushElemProp("key", key);
|
pushElemProp("key", key);
|
||||||
|
pushElemProp("ref", t.literal(null));
|
||||||
|
|
||||||
|
pushElemProp("props", props);
|
||||||
|
pushElemProp("_owner", t.literal(null));
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var _typeofReactElement = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 60103;
|
||||||
|
|
||||||
var _ref = {
|
var _ref = {
|
||||||
|
$$typeof: _typeofReactElement,
|
||||||
type: "foo",
|
type: "foo",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {},
|
props: {},
|
||||||
key: null
|
_owner: null
|
||||||
};
|
};
|
||||||
function render() {
|
function render() {
|
||||||
return _ref;
|
return _ref;
|
||||||
@ -13,12 +17,14 @@ function render() {
|
|||||||
function render() {
|
function render() {
|
||||||
var text = getText();
|
var text = getText();
|
||||||
var _ref2 = {
|
var _ref2 = {
|
||||||
|
$$typeof: _typeofReactElement,
|
||||||
type: "foo",
|
type: "foo",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {
|
props: {
|
||||||
children: text
|
children: text
|
||||||
},
|
},
|
||||||
key: null
|
_owner: null
|
||||||
};
|
};
|
||||||
return function () {
|
return function () {
|
||||||
return _ref2;
|
return _ref2;
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Baz,
|
type: Baz,
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Baz.defaultProps, {
|
props: babelHelpers.defaultProps(Baz.defaultProps, {
|
||||||
foo: "bar"
|
foo: "bar"
|
||||||
}),
|
}),
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Baz,
|
type: Baz,
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,10 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: "foo",
|
type: "foo",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {
|
props: {
|
||||||
bar: "foo"
|
bar: "foo"
|
||||||
},
|
},
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: "foo",
|
type: "foo",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {},
|
props: {},
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Foo,
|
type: Foo,
|
||||||
|
key: "foo",
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Foo.defaultProps, {}),
|
props: babelHelpers.defaultProps(Foo.defaultProps, {}),
|
||||||
key: "foo"
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,16 +1,20 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Foo,
|
type: Foo,
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Foo.defaultProps, {
|
props: babelHelpers.defaultProps(Foo.defaultProps, {
|
||||||
children: [bar, {
|
children: [bar, {
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Baz,
|
type: Baz,
|
||||||
|
key: "baz",
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
||||||
key: "baz"
|
_owner: null
|
||||||
}],
|
}],
|
||||||
className: "foo"
|
className: "foo"
|
||||||
}),
|
}),
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,11 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: "div",
|
type: "div",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {
|
props: {
|
||||||
children: bar,
|
children: bar,
|
||||||
className: "foo"
|
className: "foo"
|
||||||
},
|
},
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,16 +1,20 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: "div",
|
type: "div",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {
|
props: {
|
||||||
children: [bar, {
|
children: [bar, {
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Baz,
|
type: Baz,
|
||||||
|
key: "baz",
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
||||||
key: "baz"
|
_owner: null
|
||||||
}],
|
}],
|
||||||
className: "foo"
|
className: "foo"
|
||||||
},
|
},
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,10 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Baz,
|
type: Baz,
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Baz.defaultProps, {
|
props: babelHelpers.defaultProps(Baz.defaultProps, {
|
||||||
foo: "bar"
|
foo: "bar"
|
||||||
}),
|
}),
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Baz,
|
type: Baz,
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,10 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: "foo",
|
type: "foo",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {
|
props: {
|
||||||
bar: "foo"
|
bar: "foo"
|
||||||
},
|
},
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,8 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: "foo",
|
type: "foo",
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: {},
|
props: {},
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
@ -1,10 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
({
|
({
|
||||||
|
$$typeof: babelHelpers.typeofReactElement,
|
||||||
type: Foo,
|
type: Foo,
|
||||||
|
key: null,
|
||||||
ref: null,
|
ref: null,
|
||||||
props: babelHelpers.defaultProps(Foo.defaultProps, {
|
props: babelHelpers.defaultProps(Foo.defaultProps, {
|
||||||
bar: true
|
bar: true
|
||||||
}),
|
}),
|
||||||
key: null
|
_owner: null
|
||||||
});
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user