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

carlosrovira 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 4fb43e9  StyledUIBase: add replaceClass method
4fb43e9 is described below

commit 4fb43e971026fb495beca7921d10906d70d0378c
Author: Carlos Rovira <[email protected]>
AuthorDate: Sun Jun 14 22:58:08 2020 +0200

    StyledUIBase: add replaceClass method
---
 .../main/royale/org/apache/royale/core/StyledUIBase.as | 18 ++++++++++++++++++
 .../apache/royale/utils/IClassSelectorListSupport.as   | 13 +++++++++++++
 2 files changed, 31 insertions(+)

diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
index 1cc339a..a375c4b 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/core/StyledUIBase.as
@@ -150,6 +150,24 @@ package org.apache.royale.core
             }
         }
 
+        /**
+                *  Replace a class for a new one
+                *
+         *  @param oldClass Name of selector to remove.
+         *  @param newClass Name of selector to set.
+         * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+        public function replaceClass(oldClass:String, newClass:String = 
null):void
+        {
+            if (containsClass(oldClass))
+                removeClass(oldClass);
+            addClass(newClass == null ? oldClass : newClass);
+        }
+
         private var _emphasis:String;
         /**
                 *  Applies emphasis color display. Possible constant values 
are: PRIMARY, SECONDARY, EMPHASIZED.
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/IClassSelectorListSupport.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/IClassSelectorListSupport.as
index 0edba78..7c7dab4 100644
--- 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/IClassSelectorListSupport.as
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/IClassSelectorListSupport.as
@@ -81,5 +81,18 @@ package org.apache.royale.utils
                 *  @productversion Royale 0.9.3
                 */
                function containsClass(name:String):Boolean
+
+        /**
+                *  Replace a class for a new one. If new class is not set, use 
the old one instead
+                *
+         *  @param oldClass Name of selector to remove.
+         *  @param newClass Name of selector to set.
+         * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+        function replaceClass(oldClass:String, newClass:String = null):void
        }
 }

Reply via email to