flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [18/31] git commit: [flex-asjs] [refs/heads/develop] - fix binding bugs
Date Tue, 09 Dec 2014 05:17:05 GMT
fix binding bugs


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9de33e24
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9de33e24
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9de33e24

Branch: refs/heads/develop
Commit: 9de33e2495b34ef4af30c6d4b6668927ff47d374
Parents: bb352f9
Author: Alex Harui <aharui@apache.org>
Authored: Mon Dec 8 17:31:56 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Dec 8 20:47:43 2014 -0800

----------------------------------------------------------------------
 .../src/org/apache/flex/binding/BindingBase.js  | 31 +++++++++++++++-----
 .../org/apache/flex/binding/SimpleBinding.js    | 25 ++++++++++++++--
 2 files changed, 46 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9de33e24/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
index 77a303d..51ba089 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
@@ -82,13 +82,12 @@ org.apache.flex.binding.BindingBase.prototype.sourceID = null;
 org.apache.flex.binding.BindingBase.prototype.set_strand = function(value) {
   if (this.destination == null)
     this.destination = value;
-
-  if (this.sourceID != null)
-  {
-    try {
-      this.source = this.document['get_' + this.sourceID]();
-    } catch (e) {
-      this.source = this.document[this.sourceID];
+  if (this.sourceID != null) {
+    this.source = this.document[this.sourceID];
+    if (this.source == null) {
+      this.document.addEventListener('valueChange',
+          goog.bind(this.sourceChangeHandler, this));
+        return;
     }
   }
   else
@@ -103,3 +102,21 @@ org.apache.flex.binding.BindingBase.prototype.set_strand = function(value)
{
 org.apache.flex.binding.BindingBase.prototype.setDocument = function(document) {
   this.document = document;
 };
+
+
+/**
+ * @param {Object} event The event.
+ */
+org.apache.flex.binding.BindingBase.prototype.sourceChangeHandler = function(event) {
+  if (event.propertyName != this.sourceID)
+    return;
+
+  if (this.source)
+    this.source.removeEventListener(this.eventName,
+        goog.bind(this.changeHandler, this));
+
+  if (typeof(this.document['get_' + this.sourceID]) === 'function')
+    this.source = this.document['get_' + this.sourceID]();
+  else
+    this.source = this.document[this.sourceID];
+};

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9de33e24/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
index 5301757..de3ef28 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
@@ -50,9 +50,14 @@ org.apache.flex.binding.SimpleBinding.prototype.eventName = '';
  * @expose
  */
 org.apache.flex.binding.SimpleBinding.prototype.changeHandler = function() {
-  this.destination['set_' + this.destinationPropertyName](
-      this.source['get_' + this.sourcePropertyName]()
-  );
+  if (typeof(this.destination['set_' + this.destinationPropertyName]) === 'function')
+    this.destination['set_' + this.destinationPropertyName](
+        this.source['get_' + this.sourcePropertyName]()
+    );
+  else {
+    this.destination[this.destinationPropertyName] =
+        this.source['get_' + this.sourcePropertyName]();
+  }
 };
 
 
@@ -62,8 +67,22 @@ org.apache.flex.binding.SimpleBinding.prototype.changeHandler = function()
{
 org.apache.flex.binding.SimpleBinding.prototype.set_strand = function(value) {
   org.apache.flex.binding.SimpleBinding.base(this, 'set_strand', value);
 
+
   this.source.addEventListener(this.eventName,
       goog.bind(this.changeHandler, this));
 
   this.changeHandler();
 };
+
+
+/**
+ * @param {Object} event The event.
+ */
+org.apache.flex.binding.SimpleBinding.prototype.sourceChangeHandler = function(event) {
+  org.apache.flex.binding.SimpleBinding.base(this, 'sourceChangeHandler', event);
+  if (this.source) {
+    this.source.addEventListener(this.eventName,
+        goog.bind(this.changeHandler, this));
+    this.changeHandler();
+  }
+};
\ No newline at end of file


Mime
View raw message