[Laszlo-checkins] r13781 - in openlaszlo/trunk: WEB-INF/lps/lfc/data test/lfc/data

hqm@openlaszlo.org hqm at openlaszlo.org
Wed Apr 29 14:32:41 PDT 2009


Author: hqm
Date: 2009-04-29 14:32:37 -0700 (Wed, 29 Apr 2009)
New Revision: 13781

Added:
   openlaszlo/trunk/test/lfc/data/userdata.lzx
Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataElement.lzs
   openlaszlo/trunk/test/lfc/data/alldata.lzx
Log:
Change 20090429-hqm-L by hqm at badtzmaru.home on 2009-04-29 11:13:14 EDT
    in /Users/hqm/openlaszlo/trunk4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Implement the DOM Level3 UserData interface

New Features:

Bugs Fixed: LPP-8122

Technical Reviewer: max
QA Reviewer: andre
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:

+ implement the UserData API on LzDataElement
    
+ implementation of 'handler' has been deferred, debug warning will print if handler is passed
to setUserData


Tests:

test/lfc/data/alldata.lzx in swf9, swf8,dhtml



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataElement.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataElement.lzs	2009-04-29 19:52:20 UTC (rev 13780)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataElement.lzs	2009-04-29 21:32:37 UTC (rev 13781)
@@ -696,6 +696,68 @@
     }
 }
 
+
+/**
+ * Table to store user data objects.
+ * Stores pairs of {key := [data, handler]}
+ * @access private
+ */
+var userData:Object = null;
+
+/**
+ * Associate an object to a key on this node. The object can later be
+ * retrieved from this node by calling getUserData with the same key.
+ * (See http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-setUserData)
+
+  * @param String key: The key to associate the object to.
+  * @param Object data: The object to associate to the given key, or null to remove any existing association to that key.
+  * @param Function handler: (optional) The handler to associate to that key, or null.
+  * @return Object: the user data previously associated to the given key on this node, or null if there was none.
+  *
+  * @access public
+  * 
+  */
+public function setUserData(key:String, data:*, handler:Object = null):* {
+    if (this.userData == null) {
+        this.userData = {};
+    }
+
+    if ($debug && handler != null) {
+        Debug.warn("use of the handler arg to setUserData is not currently implemented");
+    }
+
+
+    // If there is previous data stored, our API is to return it
+    var prevdata:* = this.userData[key];
+    if (prevdata != null) {
+        prevdata = prevdata[0];
+    }
+
+    this.userData[key] = [data, handler];
+    return prevdata;
+}
+
+/**
+ * Retrieves the object associated to a key on a this node. The object
+ * must first have been set to this node by calling setUserData with the
+ * same key.
+ * (See http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-getUserData)
+  * @param String key: The key the object is associated to.
+  * @return Object: the user data associated to the given key on this node, or null if there was none.
+  *
+  * @access public
+  * 
+  */
+public function getUserData(key:String):* {
+    if (this.userData == null) {
+        return null;
+    }
+
+    var udata = this.userData[key];
+    return udata[0];
+}
+
+
 } // End of LzDataElementMixin
 lz.DataElementMixin = LzDataElementMixin;  // publish
 
@@ -739,6 +801,20 @@
         }
     }
 
+
+/* UserData API  declarations */
+/** @access private */
+public static var NODE_CLONED:int = 1; 
+/** @access private */
+public static var NODE_IMPORTED:int = 2; 
+/** @access private */
+public static var NODE_DELETED:int = 3; 
+/** @access private */
+public static var NODE_RENAMED:int = 4; 
+/** @access private */
+public static var NODE_ADOPTED:int = 5; 
+
+
 /**
   * Returns a list of empty nodes, each named 'name'.
   * @param int count: how many nodes to create.

Modified: openlaszlo/trunk/test/lfc/data/alldata.lzx
===================================================================
--- openlaszlo/trunk/test/lfc/data/alldata.lzx	2009-04-29 19:52:20 UTC (rev 13780)
+++ openlaszlo/trunk/test/lfc/data/alldata.lzx	2009-04-29 21:32:37 UTC (rev 13781)
@@ -9,6 +9,7 @@
     <include href="datapointerServerless.lzx"/>
     <include href="datapointerdependencies.lzx"/>
     <include href="datapath.lzx"/>
+    <include href="userdata.lzx"/>
     <include href="specialop.lzx"/>
     <include href="xpspace.lzx"/>
     <include href="datadollarpath.lzx"/>
@@ -40,6 +41,7 @@
         <TestDPDepend/>
         <TestDatapath/>
         <TestDatapathSpecialOp/>
+        <TestUserData/>
         <TestXPParse/>
         <TestPathBinding/>
         <TestNamespace/>

Added: openlaszlo/trunk/test/lfc/data/userdata.lzx


Property changes on: openlaszlo/trunk/test/lfc/data/userdata.lzx
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the Laszlo-checkins mailing list