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 4024dcc  jewel-datefielddisabled-bead: fix npe with bindings
4024dcc is described below

commit 4024dccfe88b185cba096667cb18086054734b5d
Author: Carlos Rovira <[email protected]>
AuthorDate: Sun Apr 21 14:35:12 2019 +0200

    jewel-datefielddisabled-bead: fix npe with bindings
---
 .../beads/controls/datefield/DateFieldDisabled.as  | 69 +++++++---------------
 1 file changed, 22 insertions(+), 47 deletions(-)

diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/datefield/DateFieldDisabled.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/datefield/DateFieldDisabled.as
index 2cd9472..395d5bb 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/datefield/DateFieldDisabled.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/datefield/DateFieldDisabled.as
@@ -18,16 +18,18 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.jewel.beads.controls.datefield
 {
-COMPILE::JS
-{
-       import org.apache.royale.core.UIBase;
+       COMPILE::JS
+       {
+       import org.apache.royale.core.IBeadView;
+       import org.apache.royale.jewel.DateField;
        import org.apache.royale.jewel.beads.views.DateFieldView;
-}
+       }
        import org.apache.royale.jewel.beads.controls.Disabled;
-       
+
        /**
-        *  The DateFieldDisabled bead class is a specialty bead that can be 
used to disable a Jewel DateField.
-        *  
+        *  The DateFieldDisabled bead class is a specialty bead that can be 
used to disable a Jewel DateField control.
+        *  This disables all the internal native controls.
+        *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
@@ -47,53 +49,26 @@ COMPILE::JS
                {
                }
 
-               /**
-                *  @copy org.apache.royale.core.IBead#strand
-                *
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion Royale 0.9.4
-                *  @royaleignorecoercion HTMLInputElement
-                *  @royaleignorecoercion org.apache.royale.core.UIBase;
-                */
-               // override public function set strand(value:IStrand):void
-               // {
-               //      _strand = value;
-
-               //      COMPILE::JS
-               //      {
-               //      if (DateField(value).numElements ==2) {
-               //              updateHost();
-               //      } else {
-               //              DateField(value).addEventListener('beadsAdded', 
onBeadsAdded);
-               //      }
-               //      }
-               // }
-
-               // COMPILE::JS
-               // private function onBeadsAdded(event:Event):void
-               // {
-               //      DateField(_strand).removeEventListener('beadsAdded', 
onBeadsAdded);
-               //      updateHost();
-               // }
-
                COMPILE::JS
                override protected function updateHost():void
                {
                        super.updateHost();
 
-                       var view:DateFieldView = (_strand as UIBase).view as 
DateFieldView;
+                       var host :DateField = _strand as DateField;
+
+                       if (host) {
+                               var view:DateFieldView = (_strand as 
DateField).view as DateFieldView;
 
-                       if (view) {
-                if(disabled) {
-                                       
view.textInput.element.setAttribute('disabled', '');
-                                       
view.menuButton.element.setAttribute('disabled', '');
-                               } else {
-                                       
view.textInput.element.removeAttribute('disabled');
-                                       
view.menuButton.element.removeAttribute('disabled');
+                               if (view) {
+                                       if (disabled) {
+                                               
view.textInput.element.setAttribute('disabled', '');
+                                               
view.menuButton.element.setAttribute('disabled', '');
+                                       } else {
+                                               
view.textInput.element.removeAttribute('disabled');
+                                               
view.menuButton.element.removeAttribute('disabled');
+                                       }
                                }
-            }
+                       }
                }
        }
 }

Reply via email to