Merge pull request #4725 from Microsoft/Port-4703

Ports of PR-4703 into release 1.6
This commit is contained in:
Vladimir Matveev 2015-09-10 12:06:01 -07:00
commit 2816fdefd0
9 changed files with 42 additions and 11 deletions

View file

@ -1292,8 +1292,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) {
function emitJsxAttribute(node: JsxAttribute) {
emit(node.name);
write("=");
emit(node.initializer);
if (node.initializer) {
write("=");
emit(node.initializer);
}
}
function emitJsxSpreadAttribute(node: JsxSpreadAttribute) {

View file

@ -0,0 +1,7 @@
//// [jsxEmitAttributeWithPreserve.tsx]
declare var React: any;
<foo data/>
//// [jsxEmitAttributeWithPreserve.jsx]
<foo data/>;

View file

@ -0,0 +1,8 @@
=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx ===
declare var React: any;
>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 11))
<foo data/>
>data : Symbol(unknown)

View file

@ -0,0 +1,10 @@
=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx ===
declare var React: any;
>React : any
<foo data/>
><foo data/> : any
>foo : any
>data : any

View file

@ -47,9 +47,9 @@ a / > ;
< a;
b > ;
b > ;
<a b= c=></a>;
<a b c></a>;
b.c > ;
<a.b c=></a.b>;
<a.b c></a.b>;
c > ;
<a.b.c></a>;
< .a > ;
@ -67,7 +67,7 @@ var x = <div>one</div><div>two</div>;;
var x = <div>one</div> /* intervening comment */ /* intervening comment */ <div>two</div>;;
<a>{"str"}}</a>;
<span className="a"/> id="b" />;
<div className=/>>;
<div className/>>;
<div {...props}/>;
<div>stuff</div>...props}>;

View file

@ -158,14 +158,14 @@ var x = <div attr1={"foo" + "bar"} attr2={"foo" + "bar" +
<Component constructor="foo"/>;
<Namespace.Component />;
<Namespace.DeepNamespace.Component />;
<Component {...x} y={2} z=/>;
<Component {...x} y={2} z/>;
<Component {...this.props} sound="moo"/>;
<font-face />;
<Component x={y}/>;
<x-component />;
<Component {...x}/>;
<Component {...x} y={2}/>;
<Component {...x} y={2} z=/>;
<Component {...x} y={2} z/>;
<Component x={1} {...y}/>;
<Component x={1} y="2" {...z} {...z}><Child /></Component>;
<Component x="1" {...(z = { y: 2 }, z)} z={3}>Text</Component>;

View file

@ -20,10 +20,10 @@ declare module JSX {
//// [tsxAttributeResolution6.jsx]
// Error
<test1 s=/>;
<test1 s/>;
<test1 n='true'/>;
<test2 />;
// OK
<test1 n=/>;
<test1 n/>;
<test1 n={false}/>;
<test2 n=/>;
<test2 n/>;

View file

@ -42,5 +42,5 @@ x3();
var x4 = <T extends={true}>() => </T>;
x4.isElement;
// This is an element
var x5 = <T extends=>() => </T>;
var x5 = <T extends>() => </T>;
x5.isElement;

View file

@ -0,0 +1,4 @@
//@jsx: preserve
declare var React: any;
<foo data/>