@tko/binding.template 4.0.0-alpha9.0 → 4.0.0-beta1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"file":"binding.template.es6.js","sources":["../src/templateSources.js","../src/templateEngine.js","../src/templating.js","../src/nativeTemplateEngine.js","../src/foreach.js","../src/index.js"],"sourcesContent":["// A template source represents a read/write way of accessing a template. This is to eliminate the need for template loading/saving\n// logic to be duplicated in every template engine (and means they can all work with anonymous templates, etc.)\n//\n// Two are provided by default:\n// 1. ko.templateSources.domElement - reads/writes the text content of an arbitrary DOM element\n// 2. ko.templateSources.anonymousElement - uses ko.utils.domData to read/write text *associated* with the DOM element, but\n// without reading/writing the actual element text content, since it will be overwritten\n// with the rendered template output.\n// You can implement your own template source if you want to fetch/store templates somewhere other than in DOM elements.\n// Template sources need to have the following functions:\n// text() \t\t\t- returns the template text from your storage location\n// text(value)\t\t- writes the supplied template text to your storage location\n// data(key)\t\t\t- reads values stored using data(key, value) - see below\n// data(key, value)\t- associates \"value\" with this template and the key \"key\". Is used to store information like \"isRewritten\".\n//\n// Optionally, template sources can also have the following functions:\n// nodes() - returns a DOM element containing the nodes of this template, where available\n// nodes(value) - writes the given DOM element to your storage location\n// If a DOM element is available for a given template source, template engines are encouraged to use it in preference over text()\n// for improved speed. However, all templateSources must supply text() even if they don't supply nodes().\n//\n// Once you've implemented a templateSource, make your template engine use it by subclassing whatever template engine you were\n// using and overriding \"makeTemplateSource\" to return an instance of your custom template source.\n\nimport {\n tagNameLower as tagNameLowerFn, setHtml, domData, parseHtmlForTemplateNodes\n} from '@tko/utils'\n\n// ---- ko.templateSources.domElement -----\n\n// template types\nvar templateScript = 1,\n templateTextArea = 2,\n templateTemplate = 3,\n templateElement = 4\n\nexport function domElement (element) {\n this.domElement = element\n\n if (!element) { return }\n var tagNameLower = tagNameLowerFn(element)\n this.templateType =\n tagNameLower === 'script' ? templateScript\n : tagNameLower === 'textarea' ? templateTextArea\n // For browsers with proper <template> element support, where the .content property gives a document fragment\n : tagNameLower == 'template' && element.content && element.content.nodeType === 11 ? templateTemplate\n : templateElement\n}\n\ndomElement.prototype.text = function (/* valueToWrite */) {\n var elemContentsProperty = this.templateType === templateScript ? 'text'\n : this.templateType === templateTextArea ? 'value'\n : 'innerHTML'\n\n if (arguments.length == 0) {\n return this.domElement[elemContentsProperty]\n } else {\n var valueToWrite = arguments[0]\n if (elemContentsProperty === 'innerHTML') { setHtml(this.domElement, valueToWrite) } else { this.domElement[elemContentsProperty] = valueToWrite }\n }\n}\n\nvar dataDomDataPrefix = domData.nextKey() + '_'\ndomElement.prototype.data = function (key /*, valueToWrite */) {\n if (arguments.length === 1) {\n return domData.get(this.domElement, dataDomDataPrefix + key)\n } else {\n domData.set(this.domElement, dataDomDataPrefix + key, arguments[1])\n }\n}\n\nvar templatesDomDataKey = domData.nextKey()\nfunction getTemplateDomData (element) {\n return domData.get(element, templatesDomDataKey) || {}\n}\nfunction setTemplateDomData (element, data) {\n domData.set(element, templatesDomDataKey, data)\n}\n\ndomElement.prototype.nodes = function (/* valueToWrite */) {\n var element = this.domElement\n if (arguments.length == 0) {\n const templateData = getTemplateDomData(element)\n let nodes = templateData.containerData || (\n this.templateType === templateTemplate ? element.content :\n this.templateType === templateElement ? element :\n undefined\n )\n if (!nodes || templateData.alwaysCheckText) {\n // If the template is associated with an element that stores the template as text,\n // parse and cache the nodes whenever there's new text content available. This allows\n // the user to update the template content by updating the text of template node.\n const text = this['text']()\n if (text) {\n nodes = parseHtmlForTemplateNodes(text, element.ownerDocument)\n this['text']('') // clear the text from the node\n setTemplateDomData(element, {containerData: nodes, alwaysCheckText: true})\n }\n }\n\n return nodes\n } else {\n var valueToWrite = arguments[0]\n setTemplateDomData(element, {containerData: valueToWrite})\n }\n}\n\n// ---- ko.templateSources.anonymousTemplate -----\n// Anonymous templates are normally saved/retrieved as DOM nodes through \"nodes\".\n// For compatibility, you can also read \"text\"; it will be serialized from the nodes on demand.\n// Writing to \"text\" is still supported, but then the template data will not be available as DOM nodes.\n\nexport function anonymousTemplate (element) {\n this.domElement = element\n}\n\nanonymousTemplate.prototype = new domElement()\nanonymousTemplate.prototype.constructor = anonymousTemplate\nanonymousTemplate.prototype.text = function (/* valueToWrite */) {\n if (arguments.length == 0) {\n var templateData = getTemplateDomData(this.domElement)\n if (templateData.textData === undefined && templateData.containerData) { templateData.textData = templateData.containerData.innerHTML }\n return templateData.textData\n } else {\n var valueToWrite = arguments[0]\n setTemplateDomData(this.domElement, {textData: valueToWrite})\n }\n}\n","// If you want to make a custom template engine,\n//\n// [1] Inherit from this class (like ko.nativeTemplateEngine does)\n// [2] Override 'renderTemplateSource', supplying a function with this signature:\n//\n// function (templateSource, bindingContext, options) {\n// // - templateSource.text() is the text of the template you should render\n// // - bindingContext.$data is the data you should pass into the template\n// // - you might also want to make bindingContext.$parent, bindingContext.$parents,\n// // and bindingContext.$root available in the template too\n// // - options gives you access to any other properties set on \"data-bind: { template: options }\"\n// // - templateDocument is the document object of the template\n// //\n// // Return value: an array of DOM nodes\n// }\n//\n// [3] Override 'createJavaScriptEvaluatorBlock', supplying a function with this signature:\n//\n// function (script) {\n// // Return value: Whatever syntax means \"Evaluate the JavaScript statement 'script' and output the result\"\n// // For example, the jquery.tmpl template engine converts 'someScript' to '${ someScript }'\n// }\n//\n// This is only necessary if you want to allow data-bind attributes to reference arbitrary template variables.\n// If you don't want to allow that, you can set the property 'allowTemplateRewriting' to false (like ko.nativeTemplateEngine does)\n// and then you don't need to override 'createJavaScriptEvaluatorBlock'.\n\nimport {\n extend, options\n} from '@tko/utils'\n\nimport {\n domElement, anonymousTemplate\n} from './templateSources'\n\nexport function templateEngine () { };\n\nextend(templateEngine.prototype, {\n renderTemplateSource: function (templateSource, bindingContext, options, templateDocument) {\n options.onError('Override renderTemplateSource')\n },\n\n createJavaScriptEvaluatorBlock: function (script) {\n options.onError('Override createJavaScriptEvaluatorBlock')\n },\n\n makeTemplateSource: function (template, templateDocument) {\n // Named template\n if (typeof template === 'string') {\n templateDocument = templateDocument || document\n var elem = templateDocument.getElementById(template)\n if (!elem) { options.onError('Cannot find template with ID ' + template) }\n return new domElement(elem)\n } else if ((template.nodeType == 1) || (template.nodeType == 8)) {\n // Anonymous template\n return new anonymousTemplate(template)\n } else { options.onError('Unknown template type: ' + template) }\n },\n\n renderTemplate: function (template, bindingContext, options, templateDocument) {\n var templateSource = this['makeTemplateSource'](template, templateDocument)\n return this.renderTemplateSource(templateSource, bindingContext, options, templateDocument)\n }\n})\n","import {\n virtualElements, fixUpContinuousNodeArray, replaceDomNodes, memoization,\n domNodeIsAttachedToDocument, moveCleanedNodesToContainerElement,\n arrayFilter, domData, options as koOptions\n} from '@tko/utils'\n\nimport {\n applyBindings, setDomNodeChildrenFromArrayMapping, AsyncBindingHandler,\n bindingEvent, bindingContext as BindingContextConstructor\n} from '@tko/bind'\n\nimport {\n computed\n} from '@tko/computed'\n\nimport {\n isObservable, dependencyDetection, unwrap, observable, isObservableArray\n} from '@tko/observable'\n\nimport {\n templateEngine\n} from './templateEngine'\n\nimport {\n anonymousTemplate as AnonymousTemplate\n} from './templateSources'\n\nvar _templateEngine\nconst cleanContainerDomDataKey = domData.nextKey()\n\nexport function setTemplateEngine (tEngine) {\n if ((tEngine !== undefined) && !(tEngine instanceof templateEngine)) {\n // TODO: ko.templateEngine to appropriate name\n throw new Error('templateEngine must inherit from ko.templateEngine')\n }\n _templateEngine = tEngine\n}\n\nfunction invokeForEachNodeInContinuousRange (firstNode, lastNode, action) {\n let node\n let nextInQueue = firstNode\n let firstOutOfRangeNode = virtualElements.nextSibling(lastNode)\n while (nextInQueue && ((node = nextInQueue) !== firstOutOfRangeNode)) {\n nextInQueue = virtualElements.nextSibling(node)\n action(node, nextInQueue)\n }\n}\n\nfunction activateBindingsOnContinuousNodeArray (continuousNodeArray, bindingContext, afterBindingCallback) {\n // To be used on any nodes that have been rendered by a template and have been inserted into some parent element\n // Walks through continuousNodeArray (which *must* be continuous, i.e., an uninterrupted sequence of sibling nodes, because\n // the algorithm for walking them relies on this), and for each top-level item in the virtual-element sense,\n // (1) Does a regular \"applyBindings\" to associate bindingContext with this node and to activate any non-memoized bindings\n // (2) Unmemoizes any memos in the DOM subtree (e.g., to activate bindings that had been memoized during template rewriting)\n\n if (continuousNodeArray.length) {\n var firstNode = continuousNodeArray[0]\n var lastNode = continuousNodeArray[continuousNodeArray.length - 1]\n var parentNode = firstNode.parentNode\n var provider = koOptions.bindingProviderInstance\n var preprocessNode = provider.preprocessNode\n\n if (preprocessNode) {\n invokeForEachNodeInContinuousRange(firstNode, lastNode, function (node, nextNodeInRange) {\n var nodePreviousSibling = node.previousSibling\n var newNodes = preprocessNode.call(provider, node)\n if (newNodes) {\n if (node === firstNode) { firstNode = newNodes[0] || nextNodeInRange }\n if (node === lastNode) { lastNode = newNodes[newNodes.length - 1] || nodePreviousSibling }\n }\n })\n\n // Because preprocessNode can change the nodes, including the first and last nodes, update continuousNodeArray to match.\n // We need the full set, including inner nodes, because the unmemoize step might remove the first node (and so the real\n // first node needs to be in the array).\n continuousNodeArray.length = 0\n if (!firstNode) { // preprocessNode might have removed all the nodes, in which case there's nothing left to do\n return\n }\n if (firstNode === lastNode) {\n continuousNodeArray.push(firstNode)\n } else {\n continuousNodeArray.push(firstNode, lastNode)\n fixUpContinuousNodeArray(continuousNodeArray, parentNode)\n }\n }\n\n // Need to applyBindings *before* unmemoziation, because unmemoization might introduce extra nodes (that we don't want to re-bind)\n // whereas a regular applyBindings won't introduce new memoized nodes\n invokeForEachNodeInContinuousRange(firstNode, lastNode, function (node) {\n if (node.nodeType === 1 || node.nodeType === 8) { applyBindings(bindingContext, node).then(afterBindingCallback) }\n })\n invokeForEachNodeInContinuousRange(firstNode, lastNode, function (node) {\n if (node.nodeType === 1 || node.nodeType === 8) { memoization.unmemoizeDomNodeAndDescendants(node, [bindingContext]) }\n })\n\n // Make sure any changes done by applyBindings or unmemoize are reflected in the array\n fixUpContinuousNodeArray(continuousNodeArray, parentNode)\n }\n}\n\nfunction getFirstNodeFromPossibleArray (nodeOrNodeArray) {\n return nodeOrNodeArray.nodeType ? nodeOrNodeArray\n : nodeOrNodeArray.length > 0 ? nodeOrNodeArray[0]\n : null\n}\n\nfunction executeTemplate (targetNodeOrNodeArray, renderMode, template, bindingContext, options, afterBindingCallback) {\n options = options || {}\n var firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray)\n var templateDocument = (firstTargetNode || template || {}).ownerDocument\n var templateEngineToUse = (options.templateEngine || _templateEngine)\n var renderedNodesArray = templateEngineToUse.renderTemplate(template, bindingContext, options, templateDocument)\n\n // Loosely check result is an array of DOM nodes\n if ((typeof renderedNodesArray.length !== 'number') || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType !== 'number')) { throw new Error('Template engine must return an array of DOM nodes') }\n\n var haveAddedNodesToParent = false\n switch (renderMode) {\n case 'replaceChildren':\n virtualElements.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray)\n haveAddedNodesToParent = true\n break\n case 'replaceNode':\n replaceDomNodes(targetNodeOrNodeArray, renderedNodesArray)\n haveAddedNodesToParent = true\n break\n case 'ignoreTargetNode': break\n default:\n throw new Error('Unknown renderMode: ' + renderMode)\n }\n\n if (haveAddedNodesToParent) {\n activateBindingsOnContinuousNodeArray(renderedNodesArray, bindingContext, afterBindingCallback)\n if (options.afterRender) { dependencyDetection.ignore(options.afterRender, null, [renderedNodesArray, bindingContext['$data']]) }\n if (renderMode === 'replaceChildren') {\n bindingEvent.notify(targetNodeOrNodeArray, bindingEvent.childrenComplete)\n }\n }\n\n return renderedNodesArray\n}\n\nfunction resolveTemplateName (template, data, context) {\n // The template can be specified as:\n if (isObservable(template)) {\n // 1. An observable, with string value\n return template()\n } else if (typeof template === 'function') {\n // 2. A function of (data, context) returning a string\n return template(data, context)\n } else {\n // 3. A string\n return template\n }\n}\n\nexport function renderTemplate (template, dataOrBindingContext, options, targetNodeOrNodeArray, renderMode, afterBindingCallback) {\n options = options || {}\n if ((options.templateEngine || _templateEngine) === undefined) { throw new Error('Set a template engine before calling renderTemplate') }\n renderMode = renderMode || 'replaceChildren'\n\n if (targetNodeOrNodeArray) {\n var firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray)\n\n var whenToDispose = function () { return (!firstTargetNode) || !domNodeIsAttachedToDocument(firstTargetNode) } // Passive disposal (on next evaluation)\n var activelyDisposeWhenNodeIsRemoved = (firstTargetNode && renderMode === 'replaceNode') ? firstTargetNode.parentNode : firstTargetNode\n\n return computed( // So the DOM is automatically updated when any dependency changes\n function () {\n // Ensure we've got a proper binding context to work with\n var bindingContext = (dataOrBindingContext && (dataOrBindingContext instanceof BindingContextConstructor))\n ? dataOrBindingContext\n : new BindingContextConstructor(dataOrBindingContext, null, null, null, { 'exportDependencies': true })\n\n var templateName = resolveTemplateName(template, bindingContext.$data, bindingContext)\n const renderedNodesArray = executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext, options, afterBindingCallback)\n\n if (renderMode === 'replaceNode') {\n targetNodeOrNodeArray = renderedNodesArray\n firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray)\n }\n },\n null,\n { disposeWhen: whenToDispose, disposeWhenNodeIsRemoved: activelyDisposeWhenNodeIsRemoved }\n )\n } else {\n // We don't yet have a DOM node to evaluate, so use a memo and render the template later when there is a DOM node\n return memoization.memoize(function (domNode) {\n renderTemplate(template, dataOrBindingContext, options, domNode, 'replaceNode')\n })\n }\n}\n\nexport default function renderTemplateForEach (template, arrayOrObservableArray, options, targetNode, parentBindingContext, afterBindingCallback) {\n // Since setDomNodeChildrenFromArrayMapping always calls executeTemplateForArrayItem and then\n // activateBindingsCallback for added items, we can store the binding context in the former to use in the latter.\n var arrayItemContext\n\n // This will be called by setDomNodeChildrenFromArrayMapping to get the nodes to add to targetNode\n function executeTemplateForArrayItem (arrayValue, index) {\n // Support selecting template as a function of the data being rendered\n if (options.as) {\n if (koOptions.createChildContextWithAs) {\n arrayItemContext = parentBindingContext.createChildContext(\n arrayValue, options.as, context => { context.$index = index }\n )\n } else {\n arrayItemContext = parentBindingContext.extend({\n [options.as]: arrayValue,\n $index: index\n })\n }\n } else {\n arrayItemContext = parentBindingContext.createChildContext(arrayValue, options.as, context => { context.$index = index })\n }\n\n var templateName = resolveTemplateName(template, arrayValue, arrayItemContext)\n return executeTemplate(targetNode, 'ignoreTargetNode', templateName, arrayItemContext, options, afterBindingCallback)\n }\n\n // This will be called whenever setDomNodeChildrenFromArrayMapping has added nodes to targetNode\n var activateBindingsCallback = function (arrayValue, addedNodesArray /*, index */) {\n activateBindingsOnContinuousNodeArray(addedNodesArray, arrayItemContext, afterBindingCallback)\n if (options.afterRender) { options.afterRender(addedNodesArray, arrayValue) }\n\n // release the \"cache\" variable, so that it can be collected by\n // the GC when its value isn't used from within the bindings anymore.\n arrayItemContext = null\n }\n\n // Call setDomNodeChildrenFromArrayMapping, ignoring any observables unwrapped within (most likely from a callback function).\n // If the array items are observables, though, they will be unwrapped in executeTemplateForArrayItem and managed within setDomNodeChildrenFromArrayMapping.\n function localSetDomNodeChildrenFromArrayMapping (newArray, changeList) {\n dependencyDetection.ignore(setDomNodeChildrenFromArrayMapping, null, [targetNode, newArray, executeTemplateForArrayItem, options, activateBindingsCallback, changeList])\n bindingEvent.notify(targetNode, bindingEvent.childrenComplete)\n }\n\n const shouldHideDestroyed = (options.includeDestroyed === false) || (koOptions.foreachHidesDestroyed && !options.includeDestroyed);\n if (!shouldHideDestroyed && !options.beforeRemove && isObservableArray(arrayOrObservableArray)) {\n localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray.peek())\n var subscription = arrayOrObservableArray.subscribe(function (changeList) {\n localSetDomNodeChildrenFromArrayMapping(arrayOrObservableArray(), changeList)\n }, null, 'arrayChange')\n subscription.disposeWhenNodeIsRemoved(targetNode)\n return subscription\n } else {\n return computed(function () {\n var unwrappedArray = unwrap(arrayOrObservableArray) || []\n const unwrappedIsIterable = Symbol.iterator in unwrappedArray\n if (!unwrappedIsIterable) { unwrappedArray = [unwrappedArray] }\n if (shouldHideDestroyed) {\n // Filter out any entries marked as destroyed\n unwrappedArray = arrayFilter(unwrappedArray, function (item) {\n return item === undefined || item === null || !unwrap(item._destroy);\n })\n }\n localSetDomNodeChildrenFromArrayMapping(unwrappedArray)\n }, null, { disposeWhenNodeIsRemoved: targetNode })\n }\n}\n\nlet templateComputedDomDataKey = domData.nextKey()\n\nexport class TemplateBindingHandler extends AsyncBindingHandler {\n constructor (params) {\n super(params)\n const element = this.$element\n const bindingValue = unwrap(this.value)\n\n // Expose 'conditional' for `else` chaining.\n domData.set(element, 'conditional', {\n elseChainSatisfied: observable(true)\n })\n\n // Support anonymous templates\n if (typeof bindingValue === 'string' || bindingValue.name) {\n this.bindNamedTemplate()\n } else if ('nodes' in bindingValue) {\n this.bindNodeTemplate(bindingValue.nodes || [])\n } else {\n this.bindAnonymousTemplate()\n }\n }\n\n bindNamedTemplate () {\n // It's a named template - clear the element\n virtualElements.emptyNode(this.$element)\n }\n\n // We've been given an array of DOM nodes. Save them as the template source.\n // There is no known use case for the node array being an observable array (if the output\n // varies, put that behavior *into* your template - that's what templates are for), and\n // the implementation would be a mess, so assert that it's not observable.\n bindNodeTemplate (nodes) {\n if (isObservable(nodes)) {\n throw new Error('The \"nodes\" option must be a plain, non-observable array.')\n }\n\n // If the nodes are already attached to a KO-generated container, we reuse that container without moving the\n // elements to a new one (we check only the first node, as the nodes are always moved together)\n let container = nodes[0] && nodes[0].parentNode\n if (!container || !domData.get(container, cleanContainerDomDataKey)) {\n container = moveCleanedNodesToContainerElement(nodes)\n domData.set(container, cleanContainerDomDataKey, true)\n }\n\n new AnonymousTemplate(this.$element).nodes(container)\n }\n\n bindAnonymousTemplate () {\n // It's an anonymous template - store the element contents, then clear the element\n const templateNodes = virtualElements.childNodes(this.$element)\n if (templateNodes.length === 0) {\n throw new Error('Anonymous template defined, but no template content was provided.')\n }\n const container = moveCleanedNodesToContainerElement(templateNodes) // This also removes the nodes from their current parent\n new AnonymousTemplate(this.$element).nodes(container)\n }\n\n onValueChange () {\n const element = this.$element\n const bindingContext = this.$context\n var value = this.value\n var options = unwrap(value)\n var shouldDisplay = true\n var templateComputed = null\n var elseChainSatisfied = domData.get(element, 'conditional').elseChainSatisfied\n var templateName\n\n if (typeof options === 'string') {\n templateName = value\n options = {}\n } else {\n templateName = options.name\n\n // Support \"if\"/\"ifnot\" conditions\n if ('if' in options) {\n shouldDisplay = unwrap(options.if)\n }\n\n if (shouldDisplay && 'ifnot' in options) {\n shouldDisplay = !unwrap(options.ifnot)\n }\n }\n\n if ('foreach' in options) {\n // Render once for each data point (treating data set as empty if shouldDisplay==false)\n var dataArray = (shouldDisplay && options.foreach) || []\n templateComputed = renderTemplateForEach(templateName || element, dataArray, options, element, bindingContext, this.completeBinding)\n\n elseChainSatisfied((unwrap(dataArray) || []).length !== 0)\n } else if (shouldDisplay) {\n // Render once for this single data point (or use the viewModel if no data was provided)\n var innerBindingContext = ('data' in options)\n ? bindingContext.createStaticChildContext(options.data, options.as) // Given an explicit 'data' value, we create a child binding context for it\n : bindingContext // Given no explicit 'data' value, we retain the same binding context\n templateComputed = renderTemplate(templateName || element, innerBindingContext, options, element, undefined, this.completeBinding)\n elseChainSatisfied(true)\n } else {\n virtualElements.emptyNode(element)\n elseChainSatisfied(false)\n }\n\n // It only makes sense to have a single template computed per element (otherwise which one should have its output displayed?)\n this.disposeOldComputedAndStoreNewOne(element, templateComputed)\n }\n\n disposeOldComputedAndStoreNewOne (element, newComputed) {\n let oldComputed = domData.get(element, templateComputedDomDataKey)\n if (oldComputed && (typeof oldComputed.dispose === 'function')) { oldComputed.dispose() }\n domData.set(element, templateComputedDomDataKey, (newComputed && (!newComputed.isActive || newComputed.isActive())) ? newComputed : undefined)\n }\n\n get controlsDescendants () { return true }\n static get allowVirtualElements () { return true }\n}\n","\nimport {\n extend, options, ieVersion, makeArray, parseHtmlFragment\n} from '@tko/utils'\n\nimport {\n templateEngine\n} from './templateEngine'\n\nimport {\n setTemplateEngine\n} from './templating'\n\nexport function nativeTemplateEngine () {\n}\n\nnativeTemplateEngine.prototype = new templateEngine()\nnativeTemplateEngine.prototype.constructor = nativeTemplateEngine\nnativeTemplateEngine.prototype.renderTemplateSource = function (templateSource, bindingContext, options, templateDocument) {\n var useNodesIfAvailable = !(ieVersion < 9), // IE<9 cloneNode doesn't work properly\n templateNodesFunc = useNodesIfAvailable ? templateSource.nodes : null,\n templateNodes = templateNodesFunc ? templateSource.nodes() : null\n\n if (templateNodes) {\n return makeArray(templateNodes.cloneNode(true).childNodes)\n } else {\n var templateText = templateSource.text()\n return parseHtmlFragment(templateText, templateDocument)\n }\n}\n\nnativeTemplateEngine.instance = new nativeTemplateEngine()\nsetTemplateEngine(nativeTemplateEngine.instance)\n","\nimport {\n unwrap, peek\n} from '@tko/observable'\n\nimport {\n nativeTemplateEngine\n} from './nativeTemplateEngine'\n\nimport {\n TemplateBindingHandler\n} from './templating'\n\n// \"foreach: someExpression\" is equivalent to \"template: { foreach: someExpression }\"\n// \"foreach: { data: someExpression, afterAdd: myfn }\" is equivalent to \"template: { foreach: someExpression, afterAdd: myfn }\"\nexport class TemplateForEachBindingHandler extends TemplateBindingHandler {\n get value () {\n const modelValue = this.valueAccessor()\n const unwrappedValue = peek(modelValue) // Unwrap without setting a dependency here\n\n // If unwrappedValue is the array, pass in the wrapped value on its own\n // The value will be unwrapped and tracked within the template binding\n // (See https://github.com/SteveSanderson/knockout/issues/523)\n if (!unwrappedValue || typeof unwrappedValue.length === 'number') {\n return { foreach: modelValue, templateEngine: nativeTemplateEngine.instance }\n }\n\n // If unwrappedValue.data is the array, preserve all relevant options and unwrap again value so we get updates\n unwrap(modelValue)\n return {\n foreach: unwrappedValue.data,\n as: unwrappedValue.as,\n includeDestroyed: unwrappedValue.includeDestroyed,\n afterAdd: unwrappedValue.afterAdd,\n beforeRemove: unwrappedValue.beforeRemove,\n afterRender: unwrappedValue.afterRender,\n beforeMove: unwrappedValue.beforeMove,\n afterMove: unwrappedValue.afterMove,\n templateEngine: nativeTemplateEngine.instance\n }\n }\n}\n","\nimport {\n TemplateForEachBindingHandler\n} from './foreach'\n\nimport {\n TemplateBindingHandler\n} from './templating'\n// 'let': letBinding,\n// template: template,\n\nexport const bindings = {\n foreach: TemplateForEachBindingHandler,\n template: TemplateBindingHandler\n}\n\nexport * from './nativeTemplateEngine'\nexport * from './templateEngine'\nexport * from './templating'\nexport * from './templateSources'\n"],"names":["tagNameLower","tagNameLowerFn","bindingContext","options","koOptions","BindingContextConstructor","AnonymousTemplate"],"mappings":";;;;;;;;;;;AAAA;AACA;;;;AA8BA,IAAI,cAAc,GAAG,CAAC;EACpB,gBAAgB,GAAG,CAAC;EACpB,gBAAgB,GAAG,CAAC;EACpB,eAAe,GAAG,EAAC;;AAErB,SAAgB,UAAU,EAAE,OAAO,EAAE;EACnC,IAAI,CAAC,UAAU,GAAG,QAAO;;EAEzB,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE;EACxB,IAAIA,eAAY,GAAGC,YAAc,CAAC,OAAO,EAAC;EAC1C,IAAI,CAAC,YAAY;QACXD,eAAY,KAAK,QAAQ,GAAG,cAAc;UACxCA,eAAY,KAAK,UAAU,GAAG,gBAAgB;;UAE9CA,eAAY,IAAI,UAAU,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,EAAE,GAAG,gBAAgB;UACnG,gBAAe;CACxB;;AAED,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,8BAA8B;EACxD,IAAI,oBAAoB,GAAG,IAAI,CAAC,YAAY,KAAK,cAAc,GAAG,MAAM;+BAC3C,IAAI,CAAC,YAAY,KAAK,gBAAgB,GAAG,OAAO;+BAChD,YAAW;;EAExC,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;IACzB,OAAO,IAAI,CAAC,UAAU,CAAC,oBAA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