Skip to content

Commit 88589d7

Browse files
committed
Remove @jsx pragma requirement. Closes #40
1 parent 64cffaf commit 88589d7

File tree

6 files changed

+11
-47
lines changed

6 files changed

+11
-47
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Install-Package React.Web.Mvc4
3131
Create JSX files
3232
```javascript
3333
// /Scripts/HelloWorld.jsx
34-
/** @jsx React.DOM */
3534
var HelloWorld = React.createClass({
3635
render: function () {
3736
return (

src/React.Sample.Cassette/Content/Sample.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* This source code is licensed under the BSD-style license found in the
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
8-
*
9-
* @jsx React.DOM
108
*/
119

1210
var CommentsBox = React.createClass({

src/React.Sample.Mvc4/Content/Sample.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* This source code is licensed under the BSD-style license found in the
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
8-
*
9-
* @jsx React.DOM
108
*/
119

1210
var CommentsBox = React.createClass({

src/React.Tests/Core/JsxTransformerTests.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,14 @@ public void SetUp()
4646
}
4747

4848
[Test]
49-
public void ShouldNotTransformJsxIfNoAnnotationPresent()
49+
public void ShouldTransformJsx()
5050
{
5151
const string input = "<div>Hello World</div>";
52-
53-
var output = _jsxTransformer.TransformJsx(input);
54-
Assert.AreEqual(input, output);
55-
}
56-
57-
[Test]
58-
public void ShouldTransformJsxIfAnnotationPresent()
59-
{
60-
const string input = "/** @jsx React.DOM */ <div>Hello World</div>";
6152
_jsxTransformer.TransformJsx(input);
6253

6354
_environment.Verify(x => x.ExecuteWithLargerStackIfRequired<string>(
6455
"ReactNET_transform",
65-
"/** @jsx React.DOM */ <div>Hello World</div>",
56+
"<div>Hello World</div>",
6657
false
6758
));
6859
}
@@ -72,11 +63,11 @@ public void ShouldWrapExceptionsInJsxExeption()
7263
{
7364
_environment.Setup(x => x.ExecuteWithLargerStackIfRequired<string>(
7465
"ReactNET_transform",
75-
"/** @jsx React.DOM */ <div>Hello World</div>",
66+
"<div>Hello World</div>",
7667
false
7768
)).Throws(new Exception("Something broke..."));
7869

79-
const string input = "/** @jsx React.DOM */ <div>Hello World</div>";
70+
const string input = "<div>Hello World</div>";
8071
Assert.Throws<JsxException>(() => _jsxTransformer.TransformJsx(input));
8172
}
8273

@@ -87,7 +78,7 @@ public void ShouldThrowIfEngineNotSupported()
8778

8879
Assert.Throws<JsxUnsupportedEngineException>(() =>
8980
{
90-
_jsxTransformer.TransformJsx("/** @jsx React.DOM */ <div>Hello world</div>");
81+
_jsxTransformer.TransformJsx("<div>Hello world</div>");
9182
});
9283
}
9384

@@ -124,13 +115,13 @@ public void ShouldTransformJsxIfFileCacheHashInvalid()
124115
SetUpEmptyCache();
125116
_fileSystem.Setup(x => x.FileExists("foo.generated.js")).Returns(true);
126117
_fileSystem.Setup(x => x.ReadAsString("foo.generated.js")).Returns("/* filesystem cached invalid */");
127-
_fileSystem.Setup(x => x.ReadAsString("foo.jsx")).Returns("/** @jsx React.DOM */ <div>Hello World</div>");
118+
_fileSystem.Setup(x => x.ReadAsString("foo.jsx")).Returns("<div>Hello World</div>");
128119
_fileCacheHash.Setup(x => x.ValidateHash(It.IsAny<string>(), It.IsAny<string>())).Returns(false);
129120

130121
_jsxTransformer.TransformJsxFile("foo.jsx");
131122
_environment.Verify(x => x.ExecuteWithLargerStackIfRequired<string>(
132123
"ReactNET_transform",
133-
"/** @jsx React.DOM */ <div>Hello World</div>",
124+
"<div>Hello World</div>",
134125
false
135126
));
136127
}
@@ -140,23 +131,23 @@ public void ShouldTransformJsxIfNoCache()
140131
{
141132
SetUpEmptyCache();
142133
_fileSystem.Setup(x => x.FileExists("foo.generated.js")).Returns(false);
143-
_fileSystem.Setup(x => x.ReadAsString("foo.jsx")).Returns("/** @jsx React.DOM */ <div>Hello World</div>");
134+
_fileSystem.Setup(x => x.ReadAsString("foo.jsx")).Returns("<div>Hello World</div>");
144135

145136
_jsxTransformer.TransformJsxFile("foo.jsx");
146137
_environment.Verify(x => x.ExecuteWithLargerStackIfRequired<string>(
147138
"ReactNET_transform",
148-
"/** @jsx React.DOM */ <div>Hello World</div>",
139+
"<div>Hello World</div>",
149140
false
150141
));
151142
}
152143

153144
[Test]
154145
public void ShouldSaveTransformationResult()
155146
{
156-
_fileSystem.Setup(x => x.ReadAsString("foo.jsx")).Returns("/** @jsx React.DOM */ <div>Hello World</div>");
147+
_fileSystem.Setup(x => x.ReadAsString("foo.jsx")).Returns("<div>Hello World</div>");
157148
_environment.Setup(x => x.ExecuteWithLargerStackIfRequired<string>(
158149
"ReactNET_transform",
159-
"/** @jsx React.DOM */ <div>Hello World</div>",
150+
"<div>Hello World</div>",
160151
false
161152
)).Returns("React.DOM.div('Hello World')");
162153

src/React/JsxTransformer.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@ private string TransformJsxWithHeader(string contents, string hash = null, bool?
141141
/// <returns>JavaScript</returns>
142142
public string TransformJsx(string input, bool? useHarmony = null)
143143
{
144-
// Just return directly if there's no JSX annotation
145-
if (!input.Contains("@jsx"))
146-
{
147-
return input;
148-
}
149-
150144
EnsureJsxTransformerSupported();
151145
try
152146
{

src/System.Web.Optimization.React/JsxBundle.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,6 @@ public JsxBundle(string virtualPath) : base(virtualPath, GetTransforms())
2626
base.ConcatenationToken = ";" + Environment.NewLine;
2727
}
2828

29-
/// <summary>
30-
/// Applies the transformations.
31-
/// </summary>
32-
/// <returns>The bundle response.</returns>
33-
public override BundleResponse ApplyTransforms(BundleContext context, string bundleContent, Collections.Generic.IEnumerable<BundleFile> bundleFiles)
34-
{
35-
const string pragma = "/** @jsx React.DOM */";
36-
37-
if (!bundleContent.TrimStart().StartsWith(pragma))
38-
{
39-
bundleContent = pragma + bundleContent;
40-
}
41-
42-
return base.ApplyTransforms(context, bundleContent, bundleFiles);
43-
}
44-
4529
/// <summary>
4630
/// Gets the transformations that should be used by the bundle.
4731
/// </summary>

0 commit comments

Comments
 (0)