sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r654516 - /incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
Date Thu, 08 May 2008 13:28:11 GMT
Author: fmeschbe
Date: Thu May  8 06:28:11 2008
New Revision: 654516

URL: http://svn.apache.org/viewvc?rev=654516&view=rev
Log:
SLING-427 Support "length" property to simulate an array

Modified:
    incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java

Modified: incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java?rev=654516&r1=654515&r2=654516&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
(original)
+++ incubator/sling/trunk/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableItemMap.java
Thu May  8 06:28:11 2008
@@ -86,6 +86,11 @@
 
     @Override
     public Object get(String name, Scriptable start) {
+        // special provision for the "length" property to simulate an array
+        if ("length".equals(name)) {
+            return ScriptRuntime.toNumber(this.items.keySet().size()+"");
+        }
+
         Item item = items.get(name);
         Object result = Undefined.instance;
         if (item != null) {



Mime
View raw message