You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/09/22 06:01:53 UTC
[royale-asjs] 08/09: Fix Crux for IE11. Need to use old foreach
approach on Map.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 6a66055b9398444bcd151f58c6786a65ee98dc70
Author: greg-dove <gr...@gmail.com>
AuthorDate: Sat Sep 21 15:49:44 2019 +1200
Fix Crux for IE11. Need to use old foreach approach on Map.
---
.../royale/org/apache/royale/crux/CruxManager.as | 21 ++++-
.../apache/royale/crux/processors/ViewProcessor.as | 102 +++++++++++++++------
2 files changed, 93 insertions(+), 30 deletions(-)
diff --git a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/CruxManager.as b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/CruxManager.as
index fec1700..ea3688c 100644
--- a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/CruxManager.as
+++ b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/CruxManager.as
@@ -168,7 +168,24 @@ package org.apache.royale.crux
}
}
COMPILE::JS{
- var iterator:IteratorIterable = wiredViews.keys();
+ //Don't use an IteratorIterable approach to maintain compatibility with IE11
+ //IE11
+ //ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach
+
+ wiredViews.forEach(
+ function(value:Object, wiredView:*):void {
+ if (value == cruxInstance) {
+ tearDownWiredView(wiredView, cruxInstance);
+ }
+ } //no second 'this' arg here - we are static
+ )
+
+ //otherwise (for other browsers) IteratorIterable might be faster (tbc):
+ //both could be supported with 'if (wireViews.keys) or maybe 'if (Map.prototype.keys)' tests
+ //as a feature check, but the above is common to all, and so deferring to IE's needs for now
+ //leaving this below as possible future improvement:
+
+ /*var iterator:IteratorIterable = wiredViews.keys();
var result:* = iterator.next();
while(!result.done)
{
@@ -179,7 +196,7 @@ package org.apache.royale.crux
tearDownWiredView(wiredView, cruxInstance);
}
result = iterator.next();
- }
+ }*/
}
}
}
diff --git a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/processors/ViewProcessor.as b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/processors/ViewProcessor.as
index ed67b1b..8ec20ab 100644
--- a/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/processors/ViewProcessor.as
+++ b/frameworks/projects/Crux/src/main/royale/org/apache/royale/crux/processors/ViewProcessor.as
@@ -207,46 +207,92 @@ package org.apache.royale.crux.processors
/**
* Examine stored refs to see if any mediators have registered to
* be notified when a view of this type has been added or removed.
+ * @royaleignorecoercion Array
+ *
*/
COMPILE::JS
protected function processViewBean( bean:Bean, tagName:String ):void
{
// iterate over the keys of our Dictionary
// the keys are the types we've found in [ViewAdded] and [ViewRemoved] declarations
-
- var iterator:IteratorIterable = views.keys();
- var result:* = iterator.next();
- while ( !result.done )
- {
- var type:* = result.value;
- // check to see if the view that was added/removed is a compatible type
- // using "is" lets us match subclasses and interface implementations
- if( bean.source is type )
+
+ //Don't use an IteratorIterable approach to maintain compatibility with IE11
+ //IE11
+ //ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach
+
+
+
+ /*if (views.keys != null) {
+ var iterator:IteratorIterable = views.keys();
+ var result:* = iterator.next();
+ while ( !result.done )
{
- // get refs to all the metadata tag instances
- var refs:Array = views.get(type) as Array;
-
- // iterate over all the metadata tag instances
- for each( var ref:ViewRef in refs )
+ var type:* = result.value;
+ // check to see if the view that was added/removed is a compatible type
+ // using "is" lets us match subclasses and interface implementations
+ if( bean.source is type )
{
- // if view was added, only process [ViewAdded] tags
- // if view was removed, only process [ViewRemoved] tags
- if( ref.tag.name != tagName && ref.tag.name != VIEW_NAVIGATOR )
- continue;
-
- // if tag was declared on a method pass the view in as the only argument
- if( ref.tag.host is MetadataHostMethod )
- {
- var f:Function = ref.mediator[ ref.tag.host.name ] as Function;
- f.apply( null, [ bean.source ] );
- }
- else // if tag was declared on a property do a simple assignment
+ // get refs to all the metadata tag instances
+ var refs:Array = views.get(type) as Array;
+
+ // iterate over all the metadata tag instances
+ for each( var ref:ViewRef in refs )
{
- ref.mediator[ ref.tag.host.name ] = bean.source;
+ // if view was added, only process [ViewAdded] tags
+ // if view was removed, only process [ViewRemoved] tags
+ if( ref.tag.name != tagName && ref.tag.name != VIEW_NAVIGATOR )
+ continue;
+
+ // if tag was declared on a method pass the view in as the only argument
+ if( ref.tag.host is MetadataHostMethod )
+ {
+ var f:Function = ref.mediator[ ref.tag.host.name ] as Function;
+ f.apply( null, [ bean.source ] );
+ }
+ else // if tag was declared on a property do a simple assignment
+ {
+ ref.mediator[ ref.tag.host.name ] = bean.source;
+ }
}
}
}
- }
+ } else {*/
+ //IE11
+ views.forEach(
+ function(value:Object, key:Object):void{
+ var type:* = key;
+ // check to see if the view that was added/removed is a compatible type
+ // using "is" lets us match subclasses and interface implementations
+ if( bean.source is type )
+ {
+ // get refs to all the metadata tag instances
+ var refs:Array = value/*views.get(type)*/ as Array;
+
+ // iterate over all the metadata tag instances
+ for each( var ref:ViewRef in refs )
+ {
+ // if view was added, only process [ViewAdded] tags
+ // if view was removed, only process [ViewRemoved] tags
+ if( ref.tag.name != tagName && ref.tag.name != VIEW_NAVIGATOR )
+ continue;
+
+ // if tag was declared on a method pass the view in as the only argument
+ if( ref.tag.host is MetadataHostMethod )
+ {
+ var f:Function = ref.mediator[ ref.tag.host.name ] as Function;
+ f.apply( null, [ bean.source ] );
+ }
+ else // if tag was declared on a property do a simple assignment
+ {
+ ref.mediator[ ref.tag.host.name ] = bean.source;
+ }
+ }
+ }
+ } //no need for second 'this' argument
+ )
+
+ //}
+
}
}
}