// @require: OpenLayers/Tile.js
/**
* @class
*/
OpenLayers.Tile.Image = Class.create();
OpenLayers.Tile.Image.prototype = 
  Object.extend( new OpenLayers.Tile(), {
    
    /** @type DOMElement img */
    img:null,

    /** 
    * @constructor
    *
    * @param {OpenLayers.Grid} layer
    * @param {OpenLayers.Pixel} position
    * @param {OpenLayers.Bounds} bounds
    * @param {String} url
    * @param {OpenLayers.Size} size
    */
    initialize: function(layer, position, bounds, url, size) {
        OpenLayers.Tile.prototype.initialize.apply(this, arguments);
    },

    destroy: function() {
        this.layer.div.removeChild(this.img);
        this.img = null;
    },

    /**
    */
    draw:function() {
        OpenLayers.Tile.prototype.draw.apply(this, arguments);
        this.img = OpenLayers.Util.createImage(null,
                                               this.position,
                                               this.size,
                                               this.url,
                                               "absolute");
        this.layer.div.appendChild(this.img);
    },

    /** @final @type String */
    CLASS_NAME: "OpenLayers.Tile.Image"
  }
);

// @require: OpenLayers/Tile.js
/**
* @class
*/
OpenLayers.Tile.Image = Class.create();
OpenLayers.Tile.Image.prototype = 
  Object.extend( new OpenLayers.Tile(), {
    
    /** @type DOMElement img */
    img:null,

    /** 
    * @constructor
    *
    * @param {OpenLayers.Grid} layer
    * @param {OpenLayers.Pixel} position
    * @param {OpenLayers.Bounds} bounds
    * @param {String} url
    * @param {OpenLayers.Size} size
    */
    initialize: function(layer, position, bounds, url, size) {
        OpenLayers.Tile.prototype.initialize.apply(this, arguments);
    },

    destroy: function() {
        if (this.img.parentNode == this.layer.div) {
            this.layer.div.removeChild(this.img);
        }
        this.img = null;
    },

    /**
    */
    draw:function() {
        OpenLayers.Tile.prototype.draw.apply(this, arguments);
        this.img = OpenLayers.Util.createImage(null,
                                               this.position,
                                               this.size,
                                               this.url,
                                               "absolute");
        this.layer.div.appendChild(this.img);
    },

    /** @final @type String */
    CLASS_NAME: "OpenLayers.Tile.Image"
  }
);

Fix for bug introduced with r510. Only make the removeChild call if the parentNode is properly set. This way we can zap the grid div contents quickly with the div.innerHTML = "" but still have a valid good destroy() function.
Fix for bug introduced with r510. Only make the removeChild call if the parentNode is properly set. This way we can zap the grid div contents quickly with the div.innerHTML = "" but still have a valid good destroy() function.

git-svn-id: 86a4f41f9d0383640198789122b520d4105b319a@511 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
