Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opichals/511374 to your computer and use it in GitHub Desktop.
Save opichals/511374 to your computer and use it in GitHub Desktop.
From 6ace654dac086185c8158e341887dd929c7c234a Mon Sep 17 00:00:00 2001
From: Standa Opichal <opichals@gmail.com>
Date: Fri, 6 Aug 2010 15:29:44 +0200
Subject: [PATCH 3/3] Avoid touching the s.rawNode internals in destroy() and rather keep the _nodeName in the dojox.gfx.Surface instance to remove the surfaces[] entry.
This avoid SL crashing in case the holding DOM node is not in the document or is hidden at the time in which case it would report invalidObject error.
---
gfx/silverlight.js | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gfx/silverlight.js b/gfx/silverlight.js
index ce3be25..9190b4e 100644
--- a/gfx/silverlight.js
+++ b/gfx/silverlight.js
@@ -504,7 +504,7 @@ dojo.declare("dojox.gfx.Surface", dojox.gfx.shape.Surface, {
},
destroy: function(){
window[this._onLoadName] = dojox.gfx.silverlight.nullFunc;
- delete dojox.gfx.silverlight.surfaces[this.rawNode.name];
+ delete dojox.gfx.silverlight.surfaces[this._nodeName];
this.inherited(arguments);
},
setDimensions: function(width, height){
@@ -548,16 +548,17 @@ dojox.gfx.createSurface = function(parentNode, width, height){
height = height + "px";
}
+ var nodeName = dojox.gfx._base._getUniqueId();
var s = new dojox.gfx.Surface();
parentNode = dojo.byId(parentNode);
+ s._nodeName = nodeName;
s._parent = parentNode;
// create an empty canvas
var t = parentNode.ownerDocument.createElement("script");
t.type = "text/xaml";
t.id = dojox.gfx._base._getUniqueId();
- t.text = "<?xml version='1.0'?><Canvas xmlns='http://schemas.microsoft.com/client/2007' Name='" +
- dojox.gfx._base._getUniqueId() + "'/>";
+ t.text = "<?xml version='1.0'?><Canvas xmlns='http://schemas.microsoft.com/client/2007' Name='" + nodeName + "'/>";
parentNode.parentNode.insertBefore(t, parentNode);
s._nodes.push(t);
@@ -570,7 +571,7 @@ dojox.gfx.createSurface = function(parentNode, width, height){
if(!s.rawNode){
s.rawNode = dojo.byId(pluginName).content.root;
// register the plugin with its parent node
- dojox.gfx.silverlight.surfaces[s.rawNode.name] = parentNode;
+ dojox.gfx.silverlight.surfaces[nodeName] = parentNode;
s.onLoad(s);
console.log("Silverlight: assigned");
}
@@ -603,7 +604,7 @@ dojox.gfx.createSurface = function(parentNode, width, height){
// the plugin was created synchronously
s.rawNode = pluginNode.content.root;
// register the plugin with its parent node
- dojox.gfx.silverlight.surfaces[s.rawNode.name] = parentNode;
+ dojox.gfx.silverlight.surfaces[nodeName] = parentNode;
}else{
// the plugin is being created asynchronously
s.rawNode = null;
--
1.7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment