You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by ps...@apache.org on 2011/04/05 12:56:36 UTC

svn commit: r1088968 - /incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js

Author: psharples
Date: Tue Apr  5 10:56:36 2011
New Revision: 1088968

URL: http://svn.apache.org/viewvc?rev=1088968&view=rev
Log:
Updated patch for IE concerning meta-data attributes which are read-only. SEE WOOKIE-205.

Modified:
    incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js

Modified: incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js?rev=1088968&r1=1088967&r2=1088968&view=diff
==============================================================================
--- incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js (original)
+++ incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js Tue Apr  5 10:56:36 2011
@@ -155,18 +155,29 @@ var Widget = {
 		WidgetImpl.metadata(this.instanceid_key, this.setMetadata);
 		dwr.engine.endBatch({async:false});
 	},
-	
+
 	setMetadata: function(map){
-		Widget.id = map["id"];
-		Widget.author = map["author"];
-		Widget.authorEmail = map["authorEmail"];
-		Widget.authorHref = map["authorHref"];
-		Widget.name = map["name"];
-		Widget.shortName = map["shortName"];
-		Widget.description = map["description"];
-		Widget.version = map["version"];
-		Widget.height = parseInt(map["height"]);
-		Widget.width = parseInt(map["width"]);
+		for (var key in map){
+			Widget.setMetadataProperty(key, map[key]);
+		}
+	},
+
+	setMetadataProperty: function(key, value){
+		try{
+			Widget.__defineSetter__(key, function(){window.DOMException.code = DOMException.NO_MODIFICATION_ALLOWED_ERR;throw (window.DOMException);});
+			Widget.__defineGetter__(key, function(){return value});
+		} catch(err){
+			try{
+				// cant use __defineGetter__ so try to setup for IE9
+				Object.defineProperty(Widget, key, {
+					set: function set(){window.DOMException.code = DOMException.NO_MODIFICATION_ALLOWED_ERR;throw (window.DOMException)},
+					get: function get(){return value}
+				}
+				);
+			} catch(err2){// catch IE8
+				eval("Widget."+key+"='"+value+"';");
+			}
+		}
 	},
 	
 	setPrefs: function(map){