Last change
on this file since 483 was
483,
checked in by hendrikvanantwerpen, 11 years ago
|
Added Dojo 1.9.3 release.
|
File size:
1.1 KB
|
Line | |
---|
1 | define([ |
---|
2 | "dojo/_base/lang", |
---|
3 | "dojo/dom", |
---|
4 | "../Context", |
---|
5 | "../dom", |
---|
6 | "../_base" |
---|
7 | ], function(lang,dom,ddc,dddom,dd){ |
---|
8 | |
---|
9 | var ddrd = lang.getObject("render.dom", true, dd); |
---|
10 | /*===== |
---|
11 | ddrd = { |
---|
12 | // TODO: summary |
---|
13 | }; |
---|
14 | =====*/ |
---|
15 | |
---|
16 | ddrd.Render = function(/*DOMNode?*/ attachPoint, /*dojox/dtl/DomTemplate?*/ tpl){ |
---|
17 | this._tpl = tpl; |
---|
18 | this.domNode = dom.byId(attachPoint); |
---|
19 | }; |
---|
20 | lang.extend(ddrd.Render, { |
---|
21 | setAttachPoint: function(/*Node*/ node){ |
---|
22 | this.domNode = node; |
---|
23 | }, |
---|
24 | render: function(/*Object*/ context, /*dojox/dtl/DomTemplate?*/ tpl, /*dojox/dtl/DomBuffer?*/ buffer){ |
---|
25 | if(!this.domNode){ |
---|
26 | throw new Error("You cannot use the Render object without specifying where you want to render it"); |
---|
27 | } |
---|
28 | |
---|
29 | this._tpl = tpl = tpl || this._tpl; |
---|
30 | buffer = buffer || tpl.getBuffer(); |
---|
31 | context = context || new ddc(); |
---|
32 | |
---|
33 | var frag = tpl.render(context, buffer).getParent(); |
---|
34 | if(!frag){ |
---|
35 | throw new Error("Rendered template does not have a root node"); |
---|
36 | } |
---|
37 | |
---|
38 | if(this.domNode !== frag){ |
---|
39 | if(this.domNode.parentNode){ |
---|
40 | this.domNode.parentNode.replaceChild(frag, this.domNode); |
---|
41 | } |
---|
42 | this.domNode = frag; |
---|
43 | } |
---|
44 | } |
---|
45 | }); |
---|
46 | |
---|
47 | return ddrd; |
---|
48 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.