You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/11/11 15:25:28 UTC

[3/4] git commit: [flex-falcon] [refs/heads/develop] - compiler: fixed issue where whitespace was not ignored if that was all that appeared between tags in JSX LiteralEmitter

compiler: fixed issue where whitespace was not ignored if that was all that appeared between tags in JSX LiteralEmitter


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/0ae03f07
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/0ae03f07
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/0ae03f07

Branch: refs/heads/develop
Commit: 0ae03f076aabab6da9f142a6e1b48498d55125f6
Parents: 8672a9e
Author: Josh Tynjala <jo...@gmail.com>
Authored: Thu Nov 10 18:42:08 2016 -0800
Committer: Josh Tynjala <jo...@gmail.com>
Committed: Thu Nov 10 18:42:08 2016 -0800

----------------------------------------------------------------------
 .../internal/codegen/js/jx/LiteralEmitter.java  |  8 +++++--
 .../codegen/js/flexjs/TestFlexJSJSX.java        | 24 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0ae03f07/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
index 5892874..58b3f07 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
@@ -302,8 +302,12 @@ public class LiteralEmitter extends JSSubEmitter implements
                             nextTagStartIndex = value.length();
                         }
                         String elementText = value.substring(0, nextTagStartIndex);
-                        writeToken(ASEmitterTokens.COMMA);
-                        emitJSXText(elementText);
+                        //ignore pure whitespace between tags
+                        if (!elementText.matches("\\s+"))
+                        {
+                            writeToken(ASEmitterTokens.COMMA);
+                            emitJSXText(elementText);
+                        }
                         value = value.substring(nextTagStartIndex);
                         continue;
                     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0ae03f07/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSJSX.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSJSX.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSJSX.java
index 1ba71df..eee9b40 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSJSX.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSJSX.java
@@ -229,6 +229,30 @@ public class TestFlexJSJSX extends ASTestBase
     }
 
     @Test
+    public void testNestedHTMLTagsWithWhitespace()
+    {
+        IFunctionNode node = getMethod("[JSX]\nfunction foo() {return <div>  \t<button/>   \t   </div>}");
+        asBlockWalker.visitFunction(node);
+        assertOut("FalconTest_A.prototype.foo = function() {\n  return React.createElement('div', null,\n    React.createElement('button', null));\n}");
+    }
+
+    @Test
+    public void testNestedHTMLTagsOnDifferentLines()
+    {
+        IFunctionNode node = getMethod("[JSX]\nfunction foo() {return <div>\n<button/>\n</div>}");
+        asBlockWalker.visitFunction(node);
+        assertOut("FalconTest_A.prototype.foo = function() {\n  return React.createElement('div', null,\n    React.createElement('button', null));\n}");
+    }
+
+    @Test
+    public void testNestedHTMLTagsOnDifferentLinesWithCRLF()
+    {
+        IFunctionNode node = getMethod("[JSX]\nfunction foo() {return <div>\r\n\t<button/>\r\n</div>}");
+        asBlockWalker.visitFunction(node);
+        assertOut("FalconTest_A.prototype.foo = function() {\n  return React.createElement('div', null,\n    React.createElement('button', null));\n}");
+    }
+
+    @Test
     public void testImportedClass()
     {
         IFunctionNode node = getMethod("[JSX]\nfunction foo() {\n  import flash.events.EventDispatcher;\n  return <EventDispatcher/>;\n}");