You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2018/05/04 18:50:51 UTC

[royale-asjs] branch develop updated: MDL: Fix issue where parent during changes of component className was undefined (reference #222)

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

piotrz 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 88cffe9  MDL: Fix issue where parent during changes of component className was undefined (reference #222)
88cffe9 is described below

commit 88cffe995de541584024cbf38eb016acfc677f98
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Fri May 4 20:50:44 2018 +0200

    MDL: Fix issue where parent during changes of component className was undefined (reference #222)
---
 .../src/main/royale/MDLClasses.as                  |  4 ++
 .../org/apache/royale/mdl/NavigationLayout.as      | 13 +++++-
 .../royale/mdl/utils/getMdlContainerParent.as      | 52 ++++++++++++++++++++++
 3 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as b/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as
index e98aa02..15c4a11 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as
@@ -40,6 +40,10 @@ package
 		import org.apache.royale.mdl.beads.UpgradeChildren; UpgradeChildren;
 		import org.apache.royale.mdl.beads.controllers.DropDownListController; DropDownListController;
 
+		COMPILE::JS
+		{
+			import org.apache.royale.mdl.utils.getMdlContainerParent; getMdlContainerParent;
+		}
 		COMPILE::SWF
 		{
 			import org.apache.royale.mdl.beads.views.SliderThumbView; org.apache.royale.mdl.beads.views.SliderThumbView;
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/NavigationLayout.as b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/NavigationLayout.as
index 316a79b..af29b46 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/NavigationLayout.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/NavigationLayout.as
@@ -22,10 +22,12 @@ package org.apache.royale.mdl
 	import org.apache.royale.events.Event;
 	import org.apache.royale.html.Group;
     import org.apache.royale.utils.ClassSelectorList;
+	import org.apache.royale.core.IParent;
 
-    COMPILE::JS
+	COMPILE::JS
     {
         import org.apache.royale.core.WrappedHTMLElement;
+        import org.apache.royale.mdl.utils.getMdlContainerParent;
     }
 
 	/**
@@ -140,5 +142,14 @@ package org.apache.royale.mdl
         {
             classSelectorList.addNames(value);
         }
+
+        /**
+         * @royaleignorecoercion org.apache.royale.core.IParent
+         */
+        COMPILE::JS
+        override public function get parent():IParent
+        {
+			return getMdlContainerParent(this.positioner);
+        }
 	}
 }
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/utils/getMdlContainerParent.as b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/utils/getMdlContainerParent.as
new file mode 100644
index 0000000..3620450
--- /dev/null
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/utils/getMdlContainerParent.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 "Licens"); 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.mdl.utils
+{
+    import org.apache.royale.core.IParent;
+    COMPILE::JS
+    {
+        import org.apache.royale.core.WrappedHTMLElement;
+    }
+
+    /**
+     *  To some MDL components after upgrading process
+     *  MDL framework adding additional container which is not part of Royale.
+     *  Function is trying to return parent component of that added container.
+     *
+     *  @langversion 3.0
+     *  @productversion Royale 0.9.4
+     *
+     *  @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+     *  @royaleignorecoercion org.apache.royale.core.IParent
+     */
+    COMPILE::JS
+    public function getMdlContainerParent(positioner:WrappedHTMLElement):IParent
+    {
+        var p:WrappedHTMLElement = positioner.parentNode as WrappedHTMLElement;
+        var wrapper:IParent = p ? p.royale_wrapper as IParent : null;
+
+        if (!wrapper)
+        {
+            p = p ? p.parentNode as WrappedHTMLElement : null;
+            wrapper = p ? p.royale_wrapper as IParent : null;
+        }
+
+        return wrapper;
+    }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
piotrz@apache.org.