Commit 182fac25 authored by Alex Russell's avatar Alex Russell

adding dojo._destroyElement method. Fixes #2931


git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@9407 560b804f-0ae3-0310-86f3-f6aa0a117693
parent 69244f7b
...@@ -13,10 +13,6 @@ try{ ...@@ -13,10 +13,6 @@ try{
// DOM Functions // DOM Functions
// ============================= // =============================
dojo.createElement = function(obj, parent, position){
// TODO: need to finish this!
}
if(dojo.isIE && (dojo.isIE<7)){ // || dojo.isOpera){ if(dojo.isIE && (dojo.isIE<7)){ // || dojo.isOpera){
dojo.byId = function(/*String*/id, /*DocumentElement*/doc){ dojo.byId = function(/*String*/id, /*DocumentElement*/doc){
// summary: // summary:
...@@ -73,6 +69,34 @@ if(dojo.isIE && (dojo.isIE<7)){ // || dojo.isOpera){ ...@@ -73,6 +69,34 @@ if(dojo.isIE && (dojo.isIE<7)){ // || dojo.isOpera){
} }
(function(){ (function(){
/*
dojo.createElement = function(obj, parent, position){
// TODO: need to finish this!
}
*/
var _destroyContainer = null;
dojo._destroyElement = function(/*String||DomNode*/node){
// summary:
// An ID of a node or a reference to a DOM node which should be
// removed from its parent and it and all of its sub-nodes will be
// destroyed
// node:
// the element to be destroyed, either as an ID or a reference
node = dojo.byId(node);
try{
if(!_destroyContainer){
_destroyContainer = document.createElement("div");
}
_destroyContainer.appendChild(node.parentNode.removeChild(node));
// NOTE: see http://trac.dojotoolkit.org/ticket/2931. This may be a bug and not a feature
_destroyContainer.innerHTML = "";
}catch(e){
/* squelch */
}
}
var _insertBefore = function(/*Node*/node, /*Node*/ref){ var _insertBefore = function(/*Node*/node, /*Node*/ref){
ref.parentNode.insertBefore(node, ref); ref.parentNode.insertBefore(node, ref);
return true; // boolean return true; // boolean
...@@ -726,6 +750,7 @@ dojo.removeClass = function(/*HTMLElement*/node, /*String*/classStr){ ...@@ -726,6 +750,7 @@ dojo.removeClass = function(/*HTMLElement*/node, /*String*/classStr){
node.className = cls.replace(new RegExp('(^|\\s+)'+classStr+'(\\s+|$)'), "$1$2"); node.className = cls.replace(new RegExp('(^|\\s+)'+classStr+'(\\s+|$)'), "$1$2");
} }
} }
dojo.toggleClass = function(/*HTMLElement*/node, /*String*/classStr, /*Boolean?*/condition){ dojo.toggleClass = function(/*HTMLElement*/node, /*String*/classStr, /*Boolean?*/condition){
// summary: // summary:
// Adds a class to node if not present, or removes if present. // Adds a class to node if not present, or removes if present.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment