This is an automated email from the ASF dual-hosted git repository.
yishayw 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 275658e Add option to observe addition of new descendants when
forcing style inheritance.
275658e is described below
commit 275658e9c77f5f7c636d9fe3a61e997ebd52c5a1
Author: DESKTOP-RH4S838\Yishay <[email protected]>
AuthorDate: Wed May 2 12:28:31 2018 +0300
Add option to observe addition of new descendants when forcing style
inheritance.
---
.../Basic/src/main/resources/basic-manifest.xml | 1 +
.../royale/html/beads/StyleInheritanceBead.as | 24 ++++++++--
...Bead.as => StyleInheritanceWithObserverBead.as} | 54 ++++++++--------------
3 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 15c8597..65ded61 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -88,6 +88,7 @@
<component id="AccordionView"
class="org.apache.royale.html.beads.AccordionView"/>
<component id="CenterElement"
class="org.apache.royale.html.beads.CenterElement"/>
<component id="StyleInheritanceBead"
class="org.apache.royale.html.beads.StyleInheritanceBead"/>
+ <component id="StyleInheritanceWithObserverBead"
class="org.apache.royale.html.beads.StyleInheritanceWithObserverBead"/>
<component id="CrossBrowserFireListenerOverrideBead"
class="org.apache.royale.html.beads.CrossBrowserFireListenerOverrideBead" />
<component id="AccessibilityAltBead"
class="org.apache.royale.html.beads.AccessibilityAltBead" />
<component id="DataGridColumnChangePropagator"
class="org.apache.royale.html.beads.DataGridColumnChangePropagator" />
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
index 28326ed..44ac72c 100644
---
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
@@ -48,7 +48,7 @@ package org.apache.royale.html.beads
{
}
- public var styleName:String;
+ private var _styleName:String;
private var _strand:IStrand;
/**
@@ -71,13 +71,13 @@ package org.apache.royale.html.beads
* @royaleignorecoercion
org.apache.royale.core.WrappedHTMLElement
*/
COMPILE::JS
- private function get hostElement():WrappedHTMLElement
+ protected function get hostElement():WrappedHTMLElement
{
return (_strand as IRenderedObject).element;
}
COMPILE::JS
- private function initCompleteHandler(e:Event):void
+ protected function initCompleteHandler(e:Event):void
{
forceInheritanceOnDescendants();
}
@@ -98,5 +98,23 @@ package org.apache.royale.html.beads
}
}
}
+
+ /**
+ * The name of the style that is to be inherited.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 9.3
+ */
+ public function get styleName():String
+ {
+ return _styleName;
+ }
+
+ public function set styleName(value:String):void
+ {
+ _styleName = value;
+ }
}
}
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceWithObserverBead.as
similarity index 62%
copy from
frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
copy to
frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceWithObserverBead.as
index 28326ed..5996b1d 100644
---
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceBead.as
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/StyleInheritanceWithObserverBead.as
@@ -1,4 +1,4 @@
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
@@ -27,14 +27,15 @@ package org.apache.royale.html.beads
}
/**
- * The StyleInheritanceBead class forces descendadants of an
IStylableObject to inherit a style
+ * The StyleInheritanceWithObserverBead extends StyleInheritace and
makes
+ * sure that new descendants inherit as well.
*
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 9.3
*/
- public class StyleInheritanceBead implements IBead
+ public class StyleInheritanceWithObserverBead extends
StyleInheritanceBead
{
/**
* constructor.
@@ -44,12 +45,11 @@ package org.apache.royale.html.beads
* @playerversion AIR 2.6
* @productversion Royale 9.3
*/
- public function StyleInheritanceBead()
+ public function StyleInheritanceWithObserverBead()
{
+ super();
}
- public var styleName:String;
- private var _strand:IStrand;
/**
* @copy org.apache.royale.core.IBead#strand
@@ -58,45 +58,29 @@ package org.apache.royale.html.beads
* @playerversion AIR 2.6
* @productversion Royale 9.3
*/
- public function set strand(value:IStrand):void
+ override public function set strand(value:IStrand):void
{
- _strand = value;
- COMPILE::JS
- {
- (value as
IEventDispatcher).addEventListener('initComplete', initCompleteHandler);
+ super.strand = value;
+ COMPILE::JS {
+ var observer:MutationObserver = new
MutationObserver(mutationDetected);
+ observer.observe(hostElement, {childList: true,
subtree: true});
}
}
-
- /**
- * @royaleignorecoercion
org.apache.royale.core.WrappedHTMLElement
- */
- COMPILE::JS
- private function get hostElement():WrappedHTMLElement
- {
- return (_strand as IRenderedObject).element;
- }
-
- COMPILE::JS
- private function initCompleteHandler(e:Event):void
- {
- forceInheritanceOnDescendants();
- }
/**
* @royaleignorecoercion
org.apache.royale.core.WrappedHTMLElement
*/
COMPILE::JS
- private function forceInheritanceOnDescendants():void
+ private function mutationDetected(mutationsList:Array):void
{
- var elements:NodeList =
hostElement.querySelectorAll("*");
- for (var i:int = 0; i < elements.length; i++)
+ var mutationRecord:MutationRecord = mutationsList[0] as
MutationRecord;
+ var addedElements:NodeList = mutationRecord.addedNodes
as NodeList;
+ for (var i:int = 0; i < addedElements.length; i++)
{
- var htmlElement:WrappedHTMLElement =
elements[i] as WrappedHTMLElement;
- if (htmlElement)
- {
- htmlElement.style[styleName] =
"inherit";
- }
- }
+ var addedElement:WrappedHTMLElement =
addedElements[i] as WrappedHTMLElement;
+ addedElement.style[styleName] = 'inherit';
+ }
}
+
}
}
--
To stop receiving notification emails like this one, please contact
[email protected].