Ticket #5647: 5647_html_set_dijitCP.patch
| File 5647_html_set_dijitCP.patch, 5.5 kB (added by sfoster, 4 months ago) |
|---|
-
layout/ContentPane.js
5 5 6 6 dojo.require("dojo.parser"); 7 7 dojo.require("dojo.string"); 8 dojo.require("dojo.html"); 8 9 dojo.requireLocalization("dijit", "loading"); 9 10 10 11 dojo.declare( … … 33 34 // href: String 34 35 // The href of the content that displays now. 35 36 // Set this at construction if you want to load data externally when the 36 // pane is shown. (Set preload=true to load it immediately.)37 // pane is shown. (Set preload=true to load it immediately.) 37 38 // Changing href after creation doesn't have any effect; use attr('href', ...); 38 39 href: "", 39 40 … … 128 129 129 130 _checkIfSingleChild: function(){ 130 131 // summary: 131 // Test if we have exactly one widget as a child, and if so assume that we are a container for that widget,132 // Test if we have exactly one widget as a child, and if so assume that we are a container for that widget, 132 133 // and should propogate startup() and resize() calls to it. 133 134 134 135 // TODO: if there are two child widgets (a data store and a TabContainer, for example), … … 154 155 }, 155 156 156 157 setHref: function(/*String|Uri*/ href){ 157 dojo.deprecated("dijit.layout.ContentPane.setHref() is deprecated. Use attr('href', ...) instead.", "", "2.0");158 dojo.deprecated("dijit.layout.ContentPane.setHref() is deprecated. Use attr('href', ...) instead.", "", "2.0"); 158 159 return this.attr("href", href); 159 160 }, 160 161 _setHrefAttr: function(/*String|Uri*/ href){ … … 181 182 }, 182 183 _setContentAttr: function(/*String|DomNode|Nodelist*/data){ 183 184 // summary: 184 // Hook to make attr("content", ...) work.185 // Hook to make attr("content", ...) work. 185 186 // Replaces old content with data content, include style classes from old content 186 187 // data: 187 188 // the new Content may be String, DomNode or NodeList … … 200 201 201 202 this._isDownloaded = false; // must be set after _setContent(..), pathadjust in dojox.layout.ContentPane 202 203 203 if(this.parseOnLoad){204 this._createSubWidgets();205 }206 207 204 if(this.doLayout != "false" && this.doLayout !== false){ 208 205 this._checkIfSingleChild(); 209 206 if(this._singleChild && this._singleChild.resize){ … … 293 290 294 291 var displayState = this._isShown(); 295 292 296 if(this.href && 293 if(this.href && 297 294 ( 298 295 forceLoad || 299 296 (this.preload && !this.isLoaded && !this._xhrDfd) || … … 367 364 }, 368 365 369 366 _setContent: function(cont){ 367 // summary: 368 // insert the content into the container node, 369 370 370 // first get rid of child widgets 371 371 this.destroyDescendants(); 372 373 // dojo.html.set will take care of the rest of the details 374 // we provide an overide for the error handling to ensure the widget gets the errors 375 // configure the setter instance with only the relevant widget instance properties 376 // NOTE: unless we hook into attr, or provide property setters for each property, 377 // we need to re-configure the ContentSetter with each use 378 var setter = this._contentSetter; 379 if(! (setter && setter instanceof dojo.html._ContentSetter)) { 380 setter = this._contentSetter = new dojo.html._ContentSetter({ 381 node: this.containerNode, 382 _onError: dojo.hitch(this, this._onError), 383 onContentError: dojo.hitch(this, function(e){ 384 // fires if a domfault occurs when we are appending this.errorMessage 385 // like for instance if domNode is a UL and we try append a DIV 386 var errMess = this.onContentError(e); 387 try{ 388 this.containerNode.innerHTML = errMess; 389 }catch(e){ 390 console.error('Fatal '+this.id+' could not change content due to '+e.message, e); 391 } 392 })/*, 393 _onError */ 394 }); 395 }; 372 396 373 try{ 374 // ... and then get rid of child dom nodes 375 var node = this.containerNode; 376 while(node.firstChild){ 377 dojo._destroyElement(node.firstChild); 378 } 379 if(typeof cont == "string"){ 380 // dijit.ContentPane does only minimal fixes, 381 // No pathAdjustments, script retrieval, style clean etc 382 // some of these should be available in the dojox.layout.ContentPane 383 if(this.extractContent){ 384 var match = cont.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); 385 if(match){ cont = match[1]; } 386 } 387 node.innerHTML = cont; 388 }else if(cont.domNode){ 389 // single widget child 390 node.appendChild(cont.domNode); 391 }else{ 392 // domNode or NodeList 393 if(cont.nodeType){ // domNode (htmlNode 1 or textNode 3) 394 node.appendChild(cont); 395 }else{// nodelist or array such as dojo.Nodelist 396 dojo.forEach(cont, function(n){ 397 node.appendChild(n.cloneNode(true)); 398 }); 399 } 400 } 401 }catch(e){ 402 // check if a domfault occurs when we are appending this.errorMessage 403 // like for instance if domNode is a UL and we try append a DIV 404 var errMess = this.onContentError(e); 405 try{ 406 node.innerHTML = errMess; 407 }catch(e){ 408 console.error('Fatal '+this.id+' could not change content due to '+e.message, e); 409 } 410 } 397 var setterParams = dojo.mixin({ 398 cleanContent: this.cleanContent, 399 extractContent: this.extractContent, 400 parseContent: this.parseOnLoad 401 }, this._contentSetterParams || {}); 402 403 dojo.mixin(setter, setterParams); 404 405 setter.set( (dojo.isObject(cont) && cont.domNode) ? cont.domNode : cont ); 406 407 // setter params must be pulled afresh from the ContentPane each time 408 delete this._contentSetterParams 411 409 }, 412 410 413 411 _onError: function(type, err, consoleText){ … … 431 429 } 432 430 }, 433 431 432 434 433 // EVENT's, should be overide-able 435 434 onLoad: function(e){ 436 435 // summary: