Sha256: a0a5ce7eb9fd814815af93c0c47453843d9877c4eccc1a054f4d8782e2e129f5

Contents?: true

Size: 1.88 KB

Versions: 10

Compression:

Stored size: 1.88 KB

Contents

// ========================================================================
// SproutCore
// copyright 2006-2008 Sprout Systems, Inc.
// ========================================================================

require('core') ;

/**
  This object can generate HTML DOM elements from a hash-based description of 
  the nodes.  See the NodeDescriptor wiki page for complete docs.

  See https://wiki.sproutit.com/engineering/show/NodeDescriptor 

  @deprecated
*/
SC.NodeDescriptor = {
  create: function(descriptor, opts) {
    if (!opts) opts = {} ;
    // collect info from descriptor
    var tag = opts.tag || descriptor.tag || 'div' ;
    var className = opts.cssClass || descriptor.cssClass ;
    var elementId = opts.id || descriptor.id ;
    var style = opts.style || descriptor.style ;
    var innerHTML = opts.innerHTML || descriptor.innerHTML ;
    if (!innerHTML) {
      var childNodes = opts.childNodes || descriptor.childNodes ;
    } 

    // create element
    var ret = $(document.createElement(tag)) ;
    if (className) ret.className = className ;
    if (elementId) ret.id = elementId ;
    if (style) {
      for (var name in style) element.style[name.camelize()] = style[name];
    }
    
    // apply extra attributes
    for(var attr in descriptor) {
      if (this.ignoredProperties.indexOf(attr) == -1) {
        ret.setAttribute(attr,descriptor[attr]) ;
      }
    }
    
    // build child nodes, if they exist.
    if (innerHTML) {
      ret.innerHTML = innerHTML ;
    } else if (childNodes) {
      var that = this ;
      childNodes.each(function(desc) {
        ret.appendChild(that.create(desc)) ;
      }) ;
	  that=null;
	  childNodes=null;
    }
    
	try{
    	return ret ;
	}finally{
		//ie7 memory leaks
		tag=null;
		className=null;
		elementId=null;
		style=null;
		innerHTML=null;
		ret=null;
	}
  },
  
  ignoredProperties: ['tag','cssClass','id','style','childNodes','innerHTML']
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sproutcore-0.9.15 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.14 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.19 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.17 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.16 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.18 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.23 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.20 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.21 frameworks/sproutcore/foundation/node_descriptor.js
sproutcore-0.9.22 frameworks/sproutcore/foundation/node_descriptor.js