This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new bd9a4d6  added utility function for getting class from instance
bd9a4d6 is described below

commit bd9a4d63f5ae4095a605988890a830adda3f2b63
Author: Harbs <ha...@in-tools.com>
AuthorDate: Tue Dec 28 11:43:48 2021 +0200

    added utility function for getting class from instance
---
 .../projects/Core/src/main/royale/CoreClasses.as   |  1 +
 .../royale/utils/object/classFromInstance.as       | 47 +++++++++++++++++++
 .../src/test/royale/flexUnitTests/CoreTester.as    |  1 +
 .../test/royale/flexUnitTests/ObjectUtilsTest.as   | 54 ++++++++++++++++++++++
 .../internalmxml/support/ListItemRenderer.as       |  2 +-
 5 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as 
b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index 7a1dd31..df3709e 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -319,6 +319,7 @@ internal class CoreClasses
                import org.apache.royale.utils.js.loadJavascript; 
loadJavascript;
                import org.apache.royale.utils.css.loadCSS; loadCSS;
        }
+       import org.apache.royale.utils.object.classFromInstance; 
classFromInstance;
        //Package Level Functions
        import org.apache.royale.debugging.assert; assert;
        import org.apache.royale.debugging.assertType; assertType;
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/classFromInstance.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/classFromInstance.as
new file mode 100644
index 0000000..e9d84fb
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/classFromInstance.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.utils.object
+{
+       COMPILE::SWF
+       {
+               import flash.utils.getDefinitionByName;
+               import flash.utils.getQualifiedClassName;
+       }
+       /**
+        * Returns the class definition of an instance of any object.
+        * The class can be used for instantiation without having to know the 
class type
+        * or for calling static methods.
+        * The implementation is platform specific. This function hides those 
implementaiot details.
+        * 
+        *  @langversion 3.0
+        *  @productversion Royale 0.9.9
+        * 
+        */
+       public function classFromInstance(instance:Object):Class
+       {
+               COMPILE::SWF{
+                       return 
getDefinitionByName(getQualifiedClassName(instance)) as Class;
+               }
+
+               COMPILE::JS{
+                       return instance.constructor;
+               }
+               
+       }
+}
\ No newline at end of file
diff --git 
a/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as 
b/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as
index f7f3ca1..a0fb801 100644
--- a/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as
+++ b/frameworks/projects/Core/src/test/royale/flexUnitTests/CoreTester.as
@@ -44,6 +44,7 @@ package flexUnitTests
         public var stringUtilsTest:StringUtilsTest;
         public var sanitizerTest:SanitizeTest;
         public var eventsTest:EventsTest;
+        public var objectUtilTests:ObjectUtilsTest;
 
     }
 }
diff --git 
a/frameworks/projects/Core/src/test/royale/flexUnitTests/ObjectUtilsTest.as 
b/frameworks/projects/Core/src/test/royale/flexUnitTests/ObjectUtilsTest.as
new file mode 100644
index 0000000..010025d
--- /dev/null
+++ b/frameworks/projects/Core/src/test/royale/flexUnitTests/ObjectUtilsTest.as
@@ -0,0 +1,54 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests
+{
+       import org.apache.royale.core.Strand;
+       import org.apache.royale.test.asserts.*;
+       import org.apache.royale.utils.object.classFromInstance;
+
+       public class ObjectUtilsTest
+       {
+               [Before]
+               public function setUp():void
+               {
+               }
+               
+               [After]
+               public function tearDown():void
+               {
+               }
+               
+               [BeforeClass]
+               public static function setUpBeforeClass():void
+               {
+               }
+               
+               [AfterClass]
+               public static function tearDownAfterClass():void
+               {
+               }
+               
+               [Test]
+               public function testClass():void
+               {
+                       var strand:Strand = new Strand();
+                       assertEquals(classFromInstance(strand), Strand, "Error 
finding class from instance.");
+               }
+       }
+}
\ No newline at end of file
diff --git 
a/manualtests/UnitTests/src/main/royale/flexUnitTests/binding/support/bindings/royale/internalmxml/support/ListItemRenderer.as
 
b/manualtests/UnitTests/src/main/royale/flexUnitTests/binding/support/bindings/royale/internalmxml/support/ListItemRenderer.as
index c0cd467..cd5cc13 100644
--- 
a/manualtests/UnitTests/src/main/royale/flexUnitTests/binding/support/bindings/royale/internalmxml/support/ListItemRenderer.as
+++ 
b/manualtests/UnitTests/src/main/royale/flexUnitTests/binding/support/bindings/royale/internalmxml/support/ListItemRenderer.as
@@ -84,7 +84,7 @@ package 
flexUnitTests.binding.support.bindings.royale.internalmxml.support
                                {
                                if(MXMLDescriptor == null)
                                {
-                                       element.innerHTML = _text;
+                                       element.textContent = _text;
                                }
                                }
                                dispatchEvent(new Event('textChange'));

Reply via email to