flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - compiler-jx: LiteralEmitter also supports key as a special JSX attribute that should never be renamed
Date Fri, 09 Dec 2016 22:54:57 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop acde07cdc -> 19c719764


compiler-jx: LiteralEmitter also supports key as a special JSX attribute that should never
be renamed


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

Branch: refs/heads/develop
Commit: 19c719764aa87cc0f570f4b83bb3f52a7e122d77
Parents: acde07c
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Fri Dec 9 14:54:52 2016 -0800
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Fri Dec 9 14:54:52 2016 -0800

----------------------------------------------------------------------
 .../compiler/internal/codegen/js/jx/LiteralEmitter.java     | 9 ++++++---
 .../compiler/internal/codegen/js/flexjs/TestFlexJSJSX.java  | 8 ++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/19c71976/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 876e995..84e883a 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
@@ -19,6 +19,8 @@
 
 package org.apache.flex.compiler.internal.codegen.js.jx;
 
+import java.util.Arrays;
+import java.util.List;
 import java.util.Stack;
 
 import org.apache.flex.compiler.codegen.ISubEmitter;
@@ -39,6 +41,7 @@ import org.apache.flex.utils.JSXUtil;
 public class LiteralEmitter extends JSSubEmitter implements
         ISubEmitter<ILiteralNode>
 {
+    private final List<String> JSX_ATTRIBUTES_NO_RENAME = Arrays.asList("ref", "key");
 
     public LiteralEmitter(IJSEmitter emitter)
     {
@@ -387,9 +390,9 @@ public class LiteralEmitter extends JSSubEmitter implements
             }
             attributeName = attributeName.trim();
             //if it's HTML, we don't want anything to be renamed by Closure
-            //compiler. if the attribute is "ref", it's a special built-in
-            //attribute that we never want to be renamed.
-            if (isHTML || attributeName.equals("ref"))
+            //compiler. if the attribute is a special built-in value, like "ref"
+            //or "key", we never want it to be renamed.
+            if (isHTML || JSX_ATTRIBUTES_NO_RENAME.contains(attributeName))
             {
                 emitJSXText(attributeName);
             }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/19c71976/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 f2484fe..46ce977 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
@@ -362,6 +362,14 @@ public class TestFlexJSJSX extends ASTestBase
         assertOut("FalconTest_A.prototype.foo = function() {\n  return React.createElement(flash.events.EventDispatcher,
{ 'ref': 'hello' });\n}");
     }
 
+    @Test
+    public void tesClassWithKey()
+    {
+        IFunctionNode node = getMethod("[JSX]\nfunction foo() {\n  import flash.events.EventDispatcher;\n
 return <EventDispatcher key=\"hello\"/>;\n}");
+        asBlockWalker.visitFunction(node);
+        assertOut("FalconTest_A.prototype.foo = function() {\n  return React.createElement(flash.events.EventDispatcher,
{ 'key': 'hello' });\n}");
+    }
+
     @Override
     protected IBackend createBackend()
     {


Mime
View raw message