(template, dataContext, container)
| 39 | /// <resource type="css" src="//$(TARGET_DESTINATION)/css/ui-dark.css" shared="true" /> |
| 40 | Template: _Base.Namespace._lazy(function () { |
| 41 | function interpretedRender(template, dataContext, container) { |
| 42 | _WriteProfilerMark("WinJS.Binding:templateRender" + template._profilerMarkIdentifier + ",StartTM"); |
| 43 | |
| 44 | if (++template._counter === 1 && (template.debugBreakOnRender || Template._debugBreakOnRender)) { |
| 45 | debugger; // jshint ignore:line |
| 46 | } |
| 47 | |
| 48 | var workPromise = Promise.wrap(); |
| 49 | var d = container || _Global.document.createElement(template.element.tagName); |
| 50 | |
| 51 | _ElementUtilities.addClass(d, "win-template"); |
| 52 | _ElementUtilities.addClass(d, "win-loading"); |
| 53 | var that = template; |
| 54 | function done() { |
| 55 | _ElementUtilities.removeClass(d, "win-loading"); |
| 56 | _WriteProfilerMark("WinJS.Binding:templateRender" + template._profilerMarkIdentifier + ",StopTM"); |
| 57 | return extractedChild || d; |
| 58 | } |
| 59 | var initial = d.children.length; |
| 60 | var element; |
| 61 | var extractedChild; |
| 62 | var dispose = function () { |
| 63 | var bindings = _ElementUtilities.data(d).winBindings; |
| 64 | if (bindings) { |
| 65 | bindings.forEach(function (item) { |
| 66 | item.cancel(); |
| 67 | }); |
| 68 | } |
| 69 | workPromise.cancel(); |
| 70 | }; |
| 71 | if (template.extractChild) { |
| 72 | element = Fragments.renderCopy(that.href || that.element, _Global.document.createElement(that.element.tagName)).then(function (frag) { |
| 73 | var child = frag.firstElementChild; |
| 74 | extractedChild = child; |
| 75 | _Dispose.markDisposable(child, dispose); |
| 76 | d.appendChild(child); |
| 77 | return child; |
| 78 | }); |
| 79 | } else { |
| 80 | _Dispose.markDisposable(d, dispose); |
| 81 | element = Fragments.renderCopy(that.href || that.element, d); |
| 82 | } |
| 83 | var renderComplete = element. |
| 84 | then(function Template_renderImpl_renderComplete_then() { |
| 85 | var work; |
| 86 | // If no existing children, we can do the faster path of just calling |
| 87 | // on the root element... |
| 88 | // |
| 89 | if (initial === 0) { |
| 90 | work = function (f, a, b, c) { return f(extractedChild || d, a, b, c); }; |
| 91 | } else { |
| 92 | // We only grab the newly added nodes (always at the end) |
| 93 | // and in the common case of only adding a single new element |
| 94 | // we avoid the "join" overhead |
| 95 | // |
| 96 | var all = d.children; |
| 97 | if (all.length === initial + 1) { |
| 98 | work = function (f, a, b, c) { return f(all[initial], a, b, c); }; |
no test coverage detected