diff --git a/dist/maquette.js b/dist/maquette.js index 865e3b8..751ee5a 100644 --- a/dist/maquette.js +++ b/dist/maquette.js @@ -407,17 +407,21 @@ ]); } }; + var insertNode = function (parentNode, domNode, vnode, beforeNode) { + if (beforeNode) { + parentNode.insertBefore(domNode, beforeNode); + } else if (domNode.parentNode !== parentNode) { + parentNode.appendChild(domNode); + } + }; createDom = function (vnode, parentNode, insertBefore, projectionOptions) { var domNode, i, c, start = 0, type, found; var vnodeSelector = vnode.vnodeSelector; + var delayAttach = false; var doc = parentNode.ownerDocument; if (vnodeSelector === '') { domNode = vnode.domNode = doc.createTextNode(vnode.text); - if (insertBefore !== undefined) { - parentNode.insertBefore(domNode, insertBefore); - } else { - parentNode.appendChild(domNode); - } + insertNode(parentNode, domNode, vnode, insertBefore); } else { for (i = 0; i <= vnodeSelector.length; ++i) { c = vnodeSelector.charAt(i); @@ -436,21 +440,23 @@ domNode = vnode.domNode = doc.createElementNS(projectionOptions.namespace, found); } else { domNode = vnode.domNode = vnode.domNode || doc.createElement(found); + delayAttach = domNode.nodeName.indexOf('-') !== -1; if (found === 'input' && vnode.properties && vnode.properties.type !== undefined) { // IE8 and older don't support setting input type after the DOM Node has been added to the document domNode.setAttribute('type', vnode.properties.type); } } - if (insertBefore !== undefined) { - parentNode.insertBefore(domNode, insertBefore); - } else if (domNode.parentNode !== parentNode) { - parentNode.appendChild(domNode); + if (!delayAttach) { + insertNode(parentNode, domNode, vnode, insertBefore); } } start = i + 1; } } initPropertiesAndChildren(domNode, vnode, projectionOptions); + if (delayAttach) { + insertNode(parentNode, domNode, vnode, insertBefore); + } } }; updateDom = function (previous, vnode, projectionOptions) { diff --git a/dist/maquette.js.map b/dist/maquette.js.map index 089b638..5f9394a 100644 --- a/dist/maquette.js.map +++ b/dist/maquette.js.map @@ -1 +1 @@ -{"version":3,"sources":["maquette.js","../../../../src/maquette.ts"],"names":["Object","defineProperty","exports","value","NAMESPACE_W3","NAMESPACE_SVG","NAMESPACE_XLINK","emptyArray","extend","base","overrides","result","keys","forEach","key","same","vnode1","vnode2","vnodeSelector","properties","bind","toTextVNode","data","undefined","children","text","toString","domNode","appendChildren","parentSelector","insertions","main","i","length_1","length","item","Array","isArray","hasOwnProperty","push","missingTransition","Error","DEFAULT_PROJECTION_OPTIONS","namespace","eventHandlerInterceptor","styleApplyer","styleName","style","transitions","enter","exit","applyDefaultProjectionOptions","projectorOptions","checkStyleValue","styleValue","setProperties","projectionOptions","propNames","propCount","_loop_1","propName","propValue","split","token","classList","add","classNames","classNameCount","j","className","styleNames","styleCount","type","lastIndexOf","oldPropValue","evt","apply","target","setAttributeNS","setAttribute","updateProperties","previousProperties","propertiesUpdated","previousValue","on","previousOn","remove","newStyleValue","oldStyleValue","domValue","removeAttribute","findIndexOfChild","sameAs","start","nodeAdded","vNode","enterAnimation","nodeToRemove","exitAnimation","pointerEvents","removeDomNode","parentNode","removeChild","checkDistinguishable","childNodes","indexToCheck","parentVNode","operation","childNode","node","createDom","updateDom","updateChildren","vnode","oldChildren","newChildren","oldChildrenLength","newChildrenLength","oldIndex","newIndex","textUpdated","oldChild","newChild","findOldIndex","addChildren","initPropertiesAndChildren","textContent","afterCreate","insertBefore","c","found","doc","ownerDocument","createTextNode","appendChild","charAt","slice","id","createElementNS","createElement","previous","updated","newVNode","replaceChild","firstChild","afterUpdate","updateAnimation","createProjection","update","updatedVnode","h","selector","arguments","childIndex","argsLength","onlyChild","child","dom","create","document","append","beforeNode","merge","element","replace","createCache","cachedInputs","cachedOutcome","invalidate","inputs","calculation","createMapping","getSourceKey","createResult","updateResult","results","map","newSources","newKeys","oldTargets","source","sourceKey","searchIndex","createProjector","projector","propertyName","eventHandler","scheduleRender","renderCompleted","scheduled","stopped","projections","renderFunctions","doRender","renderNow","requestAnimationFrame","stop","cancelAnimationFrame","resume","renderMaquetteFunction","detach","splice"],"mappings":";;;;;;;;;;;;IAAA,a;IAOA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,MAAA,CAAOC,c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AAhB,MAAuBuK,sBAA3B,EAAmD;AAAA,wBACjDP,eAAA,CAAgBS,MAAhB,CAAuBzK,CAAvB,EAA0B,CAA1B,EADiD;AAAA,wBAEjD,OAAO+J,WAAA,CAAYU,MAAZ,CAAmBzK,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAAP,CAFiD;AAAA,qBADJ;AAAA,iBADZ;AAAA,gBAOrC,MAAM,IAAIS,KAAJ,CAAU,sCAAV,CAAN,CAPqC;AAAA,aAzC7B;AAAA,SAAZ,CA7BuE;AAAA,QAiFvE,OAAO+I,SAAP,CAjFuE;AAAA,KAA9D,C","file":"maquette.js","sourcesContent":["\"use strict\";\n// Comment that is displayed in the API documentation for the maquette module:\n/**\n * Welcome to the API documentation of the **maquette** library.\n *\n * [[http://maquettejs.org/|To the maquette homepage]]\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar NAMESPACE_W3 = 'http://www.w3.org/';\nvar NAMESPACE_SVG = NAMESPACE_W3 + '2000/svg';\nvar NAMESPACE_XLINK = NAMESPACE_W3 + '1999/xlink';\n// Utilities\nvar emptyArray = [];\nvar extend = function (base, overrides) {\n var result = {};\n Object.keys(base).forEach(function (key) {\n result[key] = base[key];\n });\n if (overrides) {\n Object.keys(overrides).forEach(function (key) {\n result[key] = overrides[key];\n });\n }\n return result;\n};\n// Hyperscript helper functions\nvar same = function (vnode1, vnode2) {\n if (vnode1.vnodeSelector !== vnode2.vnodeSelector) {\n return false;\n }\n if (vnode1.properties && vnode2.properties) {\n if (vnode1.properties.key !== vnode2.properties.key) {\n return false;\n }\n return vnode1.properties.bind === vnode2.properties.bind;\n }\n return !vnode1.properties && !vnode2.properties;\n};\nvar toTextVNode = function (data) {\n return {\n vnodeSelector: '',\n properties: undefined,\n children: undefined,\n text: data.toString(),\n domNode: null\n };\n};\nvar appendChildren = function (parentSelector, insertions, main) {\n for (var i = 0, length_1 = insertions.length; i < length_1; i++) {\n var item = insertions[i];\n if (Array.isArray(item)) {\n appendChildren(parentSelector, item, main);\n }\n else {\n if (item !== null && item !== undefined) {\n if (!item.hasOwnProperty('vnodeSelector')) {\n item = toTextVNode(item);\n }\n main.push(item);\n }\n }\n }\n};\n// Render helper functions\nvar missingTransition = function () {\n throw new Error('Provide a transitions object to the projectionOptions to do animations');\n};\nvar DEFAULT_PROJECTION_OPTIONS = {\n namespace: undefined,\n eventHandlerInterceptor: undefined,\n styleApplyer: function (domNode, styleName, value) {\n // Provides a hook to add vendor prefixes for browsers that still need it.\n domNode.style[styleName] = value;\n },\n transitions: {\n enter: missingTransition,\n exit: missingTransition\n }\n};\nvar applyDefaultProjectionOptions = function (projectorOptions) {\n return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions);\n};\nvar checkStyleValue = function (styleValue) {\n if (typeof styleValue !== 'string') {\n throw new Error('Style values must be strings');\n }\n};\nvar setProperties = function (domNode, properties, projectionOptions) {\n if (!properties) {\n return;\n }\n var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor;\n var propNames = Object.keys(properties);\n var propCount = propNames.length;\n var _loop_1 = function (i) {\n var propName = propNames[i];\n /* tslint:disable:no-var-keyword: edge case */\n var propValue = properties[propName];\n /* tslint:enable:no-var-keyword */\n if (propName === 'className') {\n throw new Error('Property \"className\" is not supported, use \"class\".');\n }\n else if (propName === 'class') {\n propValue.split(/\\s+/).forEach(function (token) { return domNode.classList.add(token); });\n }\n else if (propName === 'classes') {\n // object with string keys and boolean values\n var classNames = Object.keys(propValue);\n var classNameCount = classNames.length;\n for (var j = 0; j < classNameCount; j++) {\n var className = classNames[j];\n if (propValue[className]) {\n domNode.classList.add(className);\n }\n }\n }\n else if (propName === 'styles') {\n // object with string keys and string (!) values\n var styleNames = Object.keys(propValue);\n var styleCount = styleNames.length;\n for (var j = 0; j < styleCount; j++) {\n var styleName = styleNames[j];\n var styleValue = propValue[styleName];\n if (styleValue) {\n checkStyleValue(styleValue);\n projectionOptions.styleApplyer(domNode, styleName, styleValue);\n }\n }\n }\n else if (propName !== 'key' && propValue !== null && propValue !== undefined) {\n var type = typeof propValue;\n if (type === 'function') {\n if (propName.lastIndexOf('on', 0) === 0) {\n if (eventHandlerInterceptor) {\n propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers\n }\n if (propName === 'oninput') {\n (function () {\n // record the evt.target.value, because IE and Edge sometimes do a requestAnimationFrame between changing value and running oninput\n var oldPropValue = propValue;\n propValue = function (evt) {\n oldPropValue.apply(this, [evt]);\n evt.target['oninput-value'] = evt.target.value; // may be HTMLTextAreaElement as well\n };\n }());\n }\n domNode[propName] = propValue;\n }\n }\n else if (type === 'string' && propName !== 'value' && propName !== 'innerHTML') {\n if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') {\n domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);\n }\n else {\n domNode.setAttribute(propName, propValue);\n }\n }\n else {\n domNode[propName] = propValue;\n }\n }\n };\n for (var i = 0; i < propCount; i++) {\n _loop_1(i);\n }\n};\nvar updateProperties = function (domNode, previousProperties, properties, projectionOptions) {\n if (!properties) {\n return;\n }\n var propertiesUpdated = false;\n var propNames = Object.keys(properties);\n var propCount = propNames.length;\n for (var i = 0; i < propCount; i++) {\n var propName = propNames[i];\n // assuming that properties will be nullified instead of missing is by design\n var propValue = properties[propName];\n var previousValue = previousProperties[propName];\n if (propName === 'class') {\n if (previousValue !== propValue) {\n throw new Error('\"class\" property may not be updated. Use the \"classes\" property for conditional css classes.');\n }\n }\n else if (propName === 'classes') {\n var classList = domNode.classList;\n var classNames = Object.keys(propValue);\n var classNameCount = classNames.length;\n for (var j = 0; j < classNameCount; j++) {\n var className = classNames[j];\n var on = !!propValue[className];\n var previousOn = !!previousValue[className];\n if (on === previousOn) {\n continue;\n }\n propertiesUpdated = true;\n if (on) {\n classList.add(className);\n }\n else {\n classList.remove(className);\n }\n }\n }\n else if (propName === 'styles') {\n var styleNames = Object.keys(propValue);\n var styleCount = styleNames.length;\n for (var j = 0; j < styleCount; j++) {\n var styleName = styleNames[j];\n var newStyleValue = propValue[styleName];\n var oldStyleValue = previousValue[styleName];\n if (newStyleValue === oldStyleValue) {\n continue;\n }\n propertiesUpdated = true;\n if (newStyleValue) {\n checkStyleValue(newStyleValue);\n projectionOptions.styleApplyer(domNode, styleName, newStyleValue);\n }\n else {\n projectionOptions.styleApplyer(domNode, styleName, '');\n }\n }\n }\n else {\n if (!propValue && typeof previousValue === 'string') {\n propValue = '';\n }\n if (propName === 'value') {\n var domValue = domNode[propName];\n if (domValue !== propValue // The 'value' in the DOM tree !== newValue\n && (domNode['oninput-value']\n ? domValue === domNode['oninput-value'] // If the last reported value to 'oninput' does not match domValue, do nothing and wait for oninput\n : propValue !== previousValue // Only update the value if the vdom changed\n )) {\n domNode[propName] = propValue; // Reset the value, even if the virtual DOM did not change\n domNode['oninput-value'] = undefined;\n } // else do not update the domNode, otherwise the cursor position would be changed\n if (propValue !== previousValue) {\n propertiesUpdated = true;\n }\n }\n else if (propValue !== previousValue) {\n var type = typeof propValue;\n if (type === 'function') {\n throw new Error('Functions may not be updated on subsequent renders (property: ' + propName +\n '). Hint: declare event handler functions outside the render() function.');\n }\n if (type === 'string' && propName !== 'innerHTML') {\n if (projectionOptions.namespace === NAMESPACE_SVG && propName === 'href') {\n domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);\n }\n else if (propName === 'role' && propValue === '') {\n domNode.removeAttribute(propName);\n }\n else {\n domNode.setAttribute(propName, propValue);\n }\n }\n else {\n if (domNode[propName] !== propValue) {\n domNode[propName] = propValue;\n }\n }\n propertiesUpdated = true;\n }\n }\n }\n return propertiesUpdated;\n};\nvar findIndexOfChild = function (children, sameAs, start) {\n if (sameAs.vnodeSelector !== '') {\n // Never scan for text-nodes\n for (var i = start; i < children.length; i++) {\n if (same(children[i], sameAs)) {\n return i;\n }\n }\n }\n return -1;\n};\nvar nodeAdded = function (vNode, transitions) {\n if (vNode.properties) {\n var enterAnimation = vNode.properties.enterAnimation;\n if (enterAnimation) {\n if (typeof enterAnimation === 'function') {\n enterAnimation(vNode.domNode, vNode.properties);\n }\n else {\n transitions.enter(vNode.domNode, vNode.properties, enterAnimation);\n }\n }\n }\n};\nvar nodeToRemove = function (vNode, transitions) {\n var domNode = vNode.domNode;\n if (vNode.properties) {\n var exitAnimation = vNode.properties.exitAnimation;\n if (exitAnimation) {\n domNode.style.pointerEvents = 'none';\n var removeDomNode = function () {\n if (domNode.parentNode) {\n domNode.parentNode.removeChild(domNode);\n }\n };\n if (typeof exitAnimation === 'function') {\n exitAnimation(domNode, removeDomNode, vNode.properties);\n return;\n }\n else {\n transitions.exit(vNode.domNode, vNode.properties, exitAnimation, removeDomNode);\n return;\n }\n }\n }\n if (domNode.parentNode) {\n domNode.parentNode.removeChild(domNode);\n }\n};\nvar checkDistinguishable = function (childNodes, indexToCheck, parentVNode, operation) {\n var childNode = childNodes[indexToCheck];\n if (childNode.vnodeSelector === '') {\n return; // Text nodes need not be distinguishable\n }\n var properties = childNode.properties;\n var key = properties ? (properties.key === undefined ? properties.bind : properties.key) : undefined;\n if (!key) {\n for (var i = 0; i < childNodes.length; i++) {\n if (i !== indexToCheck) {\n var node = childNodes[i];\n if (same(node, childNode)) {\n if (operation === 'added') {\n throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' +\n 'added, but there is now more than one. You must add unique key properties to make them distinguishable.');\n }\n else {\n throw new Error(parentVNode.vnodeSelector + ' had a ' + childNode.vnodeSelector + ' child ' +\n 'removed, but there were more than one. You must add unique key properties to make them distinguishable.');\n }\n }\n }\n }\n }\n};\nvar createDom;\nvar updateDom;\nvar updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) {\n if (oldChildren === newChildren) {\n return false;\n }\n oldChildren = oldChildren || emptyArray;\n newChildren = newChildren || emptyArray;\n var oldChildrenLength = oldChildren.length;\n var newChildrenLength = newChildren.length;\n var transitions = projectionOptions.transitions;\n var oldIndex = 0;\n var newIndex = 0;\n var i;\n var textUpdated = false;\n while (newIndex < newChildrenLength) {\n var oldChild = (oldIndex < oldChildrenLength) ? oldChildren[oldIndex] : undefined;\n var newChild = newChildren[newIndex];\n if (oldChild !== undefined && same(oldChild, newChild)) {\n textUpdated = updateDom(oldChild, newChild, projectionOptions) || textUpdated;\n oldIndex++;\n }\n else {\n var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1);\n if (findOldIndex >= 0) {\n // Remove preceding missing children\n for (i = oldIndex; i < findOldIndex; i++) {\n nodeToRemove(oldChildren[i], transitions);\n checkDistinguishable(oldChildren, i, vnode, 'removed');\n }\n textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated;\n oldIndex = findOldIndex + 1;\n }\n else {\n // New child\n createDom(newChild, domNode, (oldIndex < oldChildrenLength) ? oldChildren[oldIndex].domNode : undefined, projectionOptions);\n nodeAdded(newChild, transitions);\n checkDistinguishable(newChildren, newIndex, vnode, 'added');\n }\n }\n newIndex++;\n }\n if (oldChildrenLength > oldIndex) {\n // Remove child fragments\n for (i = oldIndex; i < oldChildrenLength; i++) {\n nodeToRemove(oldChildren[i], transitions);\n checkDistinguishable(oldChildren, i, vnode, 'removed');\n }\n }\n return textUpdated;\n};\nvar addChildren = function (domNode, children, projectionOptions) {\n if (!children) {\n return;\n }\n for (var i = 0; i < children.length; i++) {\n createDom(children[i], domNode, undefined, projectionOptions);\n }\n};\nvar initPropertiesAndChildren = function (domNode, vnode, projectionOptions) {\n addChildren(domNode, vnode.children, projectionOptions); // children before properties, needed for value property of .\n if (vnode.text) {\n domNode.textContent = vnode.text;\n }\n setProperties(domNode, vnode.properties, projectionOptions);\n if (vnode.properties && vnode.properties.afterCreate) {\n vnode.properties.afterCreate.apply(vnode.properties.bind || vnode.properties, [domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children]);\n }\n};\nvar insertNode = function (parentNode, domNode, vnode, beforeNode) {\n if (beforeNode) {\n parentNode.insertBefore(domNode, beforeNode);\n }\n else if (domNode.parentNode !== parentNode) {\n parentNode.appendChild(domNode);\n }\n};\ncreateDom = function (vnode, parentNode, insertBefore, projectionOptions) {\n var domNode, i, c, start = 0, type, found;\n var vnodeSelector = vnode.vnodeSelector;\n var delayAttach = false;\n var doc = parentNode.ownerDocument;\n if (vnodeSelector === '') {\n domNode = vnode.domNode = doc.createTextNode(vnode.text);\n insertNode(parentNode, domNode, vnode, insertBefore);\n }\n else {\n for (i = 0; i <= vnodeSelector.length; ++i) {\n c = vnodeSelector.charAt(i);\n if (i === vnodeSelector.length || c === '.' || c === '#') {\n type = vnodeSelector.charAt(start - 1);\n found = vnodeSelector.slice(start, i);\n if (type === '.') {\n domNode.classList.add(found);\n }\n else if (type === '#') {\n domNode.id = found;\n }\n else {\n if (found === 'svg') {\n projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG });\n }\n if (projectionOptions.namespace !== undefined) {\n domNode = vnode.domNode = doc.createElementNS(projectionOptions.namespace, found);\n }\n else {\n domNode = vnode.domNode = (vnode.domNode || doc.createElement(found));\n delayAttach = domNode.nodeName.indexOf('-') !== -1;\n if (found === 'input' && vnode.properties && vnode.properties.type !== undefined) {\n // IE8 and older don't support setting input type after the DOM Node has been added to the document\n domNode.setAttribute('type', vnode.properties.type);\n }\n }\n if (!delayAttach) {\n insertNode(parentNode, domNode, vnode, insertBefore);\n }\n }\n start = i + 1;\n }\n }\n initPropertiesAndChildren(domNode, vnode, projectionOptions);\n if (delayAttach) {\n insertNode(parentNode, domNode, vnode, insertBefore);\n }\n }\n};\nupdateDom = function (previous, vnode, projectionOptions) {\n var domNode = previous.domNode;\n var textUpdated = false;\n if (previous === vnode) {\n return false; // By contract, VNode objects may not be modified anymore after passing them to maquette\n }\n var updated = false;\n if (vnode.vnodeSelector === '') {\n if (vnode.text !== previous.text) {\n var newVNode = domNode.ownerDocument.createTextNode(vnode.text);\n domNode.parentNode.replaceChild(newVNode, domNode);\n vnode.domNode = newVNode;\n textUpdated = true;\n return textUpdated;\n }\n }\n else {\n if (vnode.vnodeSelector.lastIndexOf('svg', 0) === 0) {\n projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG });\n }\n if (previous.text !== vnode.text) {\n updated = true;\n if (vnode.text === undefined) {\n domNode.removeChild(domNode.firstChild); // the only textnode presumably\n }\n else {\n domNode.textContent = vnode.text;\n }\n }\n updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated;\n updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated;\n if (vnode.properties && vnode.properties.afterUpdate) {\n vnode.properties.afterUpdate.apply(vnode.properties.bind || vnode.properties, [domNode, projectionOptions, vnode.vnodeSelector, vnode.properties, vnode.children]);\n }\n }\n if (updated && vnode.properties && vnode.properties.updateAnimation) {\n vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties);\n }\n vnode.domNode = previous.domNode;\n return textUpdated;\n};\nvar createProjection = function (vnode, projectionOptions) {\n return {\n update: function (updatedVnode) {\n if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) {\n throw new Error('The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)');\n }\n updateDom(vnode, updatedVnode, projectionOptions);\n vnode = updatedVnode;\n },\n domNode: vnode.domNode\n };\n};\n// The other two parameters are not added here, because the Typescript compiler creates surrogate code for destructuring 'children'.\nexports.h = function (selector) {\n var properties = arguments[1];\n if (typeof selector !== 'string') {\n throw new Error();\n }\n var childIndex = 1;\n if (properties && !properties.hasOwnProperty('vnodeSelector') && !Array.isArray(properties) && typeof properties === 'object') {\n childIndex = 2;\n }\n else {\n // Optional properties argument was omitted\n properties = undefined;\n }\n var text;\n var children;\n var argsLength = arguments.length;\n // Recognize a common special case where there is only a single text node\n if (argsLength === childIndex + 1) {\n var onlyChild = arguments[childIndex];\n if (typeof onlyChild === 'string') {\n text = onlyChild;\n }\n else if (onlyChild !== undefined && onlyChild !== null && onlyChild.length === 1 && typeof onlyChild[0] === 'string') {\n text = onlyChild[0];\n }\n }\n if (text === undefined) {\n children = [];\n for (; childIndex < argsLength; childIndex++) {\n var child = arguments[childIndex];\n if (child === null || child === undefined) {\n }\n else if (Array.isArray(child)) {\n appendChildren(selector, child, children);\n }\n else if (child.hasOwnProperty('vnodeSelector')) {\n children.push(child);\n }\n else {\n children.push(toTextVNode(child));\n }\n }\n }\n return {\n vnodeSelector: selector,\n properties: properties,\n children: children,\n text: (text === '') ? undefined : text,\n domNode: null\n };\n};\n/**\n * Contains simple low-level utility functions to manipulate the real DOM.\n */\nexports.dom = {\n /**\n * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in\n * its [[Projection.domNode|domNode]] property.\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection.\n * @returns The [[Projection]] which also contains the DOM Node that was created.\n */\n create: function (vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, document.createElement('div'), undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Appends a new child node to the DOM which is generated from a [[VNode]].\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param parentNode - The parent node for the new child node.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the [[Projection]].\n * @returns The [[Projection]] that was created.\n */\n append: function (parentNode, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, parentNode, undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Inserts a new DOM node which is generated from a [[VNode]].\n * This is a low-level method. Users wil typically use a [[Projector]] instead.\n * @param beforeNode - The node that the DOM Node is inserted before.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.\n * NOTE: [[VNode]] objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].\n * @returns The [[Projection]] that was created.\n */\n insertBefore: function (beforeNode, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.\n * This means that the virtual DOM and the real DOM will have one overlapping element.\n * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.\n * This is a low-level method. Users wil typically use a [[Projector]] instead.\n * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects\n * may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].\n * @returns The [[Projection]] that was created.\n */\n merge: function (element, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n vnode.domNode = element;\n initPropertiesAndChildren(element, vnode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Replaces an existing DOM node with a node generated from a [[VNode]].\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param element - The node for the [[VNode]] to replace.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the [[Projection]].\n * @returns The [[Projection]] that was created.\n */\n replace: function (element, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, element.parentNode, element, projectionOptions);\n element.parentNode.removeChild(element);\n return createProjection(vnode, projectionOptions);\n }\n};\n/**\n * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.\n * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.\n * For more information, see [[CalculationCache]].\n *\n * @param The type of the value that is cached.\n */\nexports.createCache = function () {\n var cachedInputs;\n var cachedOutcome;\n return {\n invalidate: function () {\n cachedOutcome = undefined;\n cachedInputs = undefined;\n },\n result: function (inputs, calculation) {\n if (cachedInputs) {\n for (var i = 0; i < inputs.length; i++) {\n if (cachedInputs[i] !== inputs[i]) {\n cachedOutcome = undefined;\n }\n }\n }\n if (!cachedOutcome) {\n cachedOutcome = calculation();\n cachedInputs = inputs;\n }\n return cachedOutcome;\n }\n };\n};\n/**\n * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects.\n * See {@link http://maquettejs.org/docs/arrays.html|Working with arrays}.\n *\n * @param The type of source items. A database-record for instance.\n * @param The type of target items. A [[Component]] for instance.\n * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number.\n * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical\n * to the `callback` argument in `Array.map(callback)`.\n * @param updateResult `function(source, target, index)` that updates a result to an updated source.\n */\nexports.createMapping = function (getSourceKey, createResult, updateResult) {\n var keys = [];\n var results = [];\n return {\n results: results,\n map: function (newSources) {\n var newKeys = newSources.map(getSourceKey);\n var oldTargets = results.slice();\n var oldIndex = 0;\n for (var i = 0; i < newSources.length; i++) {\n var source = newSources[i];\n var sourceKey = newKeys[i];\n if (sourceKey === keys[oldIndex]) {\n results[i] = oldTargets[oldIndex];\n updateResult(source, oldTargets[oldIndex], i);\n oldIndex++;\n }\n else {\n var found = false;\n for (var j = 1; j < keys.length + 1; j++) {\n var searchIndex = (oldIndex + j) % keys.length;\n if (keys[searchIndex] === sourceKey) {\n results[i] = oldTargets[searchIndex];\n updateResult(newSources[i], oldTargets[searchIndex], i);\n oldIndex = searchIndex + 1;\n found = true;\n break;\n }\n }\n if (!found) {\n results[i] = createResult(source, i);\n }\n }\n }\n results.length = newSources.length;\n keys = newKeys;\n }\n };\n};\n/**\n * Creates a [[Projector]] instance using the provided projectionOptions.\n *\n * For more information, see [[Projector]].\n *\n * @param projectorOptions Options that influence how the DOM is rendered and updated.\n */\nexports.createProjector = function (projectorOptions) {\n var projector;\n var projectionOptions = applyDefaultProjectionOptions(projectorOptions);\n projectionOptions.eventHandlerInterceptor = function (propertyName, eventHandler, domNode, properties) {\n return function () {\n // intercept function calls (event handlers) to do a render afterwards.\n projector.scheduleRender();\n return eventHandler.apply(properties.bind || this, arguments);\n };\n };\n var renderCompleted = true;\n var scheduled;\n var stopped = false;\n var projections = [];\n var renderFunctions = []; // matches the projections array\n var doRender = function () {\n scheduled = undefined;\n if (!renderCompleted) {\n return; // The last render threw an error, it should be logged in the browser console.\n }\n renderCompleted = false;\n for (var i = 0; i < projections.length; i++) {\n var updatedVnode = renderFunctions[i]();\n projections[i].update(updatedVnode);\n }\n renderCompleted = true;\n };\n projector = {\n renderNow: doRender,\n scheduleRender: function () {\n if (!scheduled && !stopped) {\n scheduled = requestAnimationFrame(doRender);\n }\n },\n stop: function () {\n if (scheduled) {\n cancelAnimationFrame(scheduled);\n scheduled = undefined;\n }\n stopped = true;\n },\n resume: function () {\n stopped = false;\n renderCompleted = true;\n projector.scheduleRender();\n },\n append: function (parentNode, renderMaquetteFunction) {\n projections.push(exports.dom.append(parentNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n insertBefore: function (beforeNode, renderMaquetteFunction) {\n projections.push(exports.dom.insertBefore(beforeNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n merge: function (domNode, renderMaquetteFunction) {\n projections.push(exports.dom.merge(domNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n replace: function (domNode, renderMaquetteFunction) {\n projections.push(exports.dom.replace(domNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n detach: function (renderMaquetteFunction) {\n for (var i = 0; i < renderFunctions.length; i++) {\n if (renderFunctions[i] === renderMaquetteFunction) {\n renderFunctions.splice(i, 1);\n return projections.splice(i, 1)[0];\n }\n }\n throw new Error('renderMaquetteFunction was not found');\n }\n };\n return projector;\n};\n\n//# sourceMappingURL=maquette.js.map\n"]} \ No newline at end of file diff --git a/dist/maquette.min.js b/dist/maquette.min.js index d4412fa..eedae7f 100644 --- a/dist/maquette.min.js +++ b/dist/maquette.min.js @@ -1,2 +1,2 @@ -!function(e,r){"function"==typeof define&&define.amd?define(["exports"],r):r("object"==typeof exports&&"string"!=typeof exports.nodeName?exports:e.maquette={})}(this,function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,t,o="http://www.w3.org/2000/svg",n=[],i=function(e,r){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r]}),r&&Object.keys(r).forEach(function(e){t[e]=r[e]}),t},s=function(e,r){return e.vnodeSelector===r.vnodeSelector&&(e.properties&&r.properties?e.properties.key===r.properties.key&&e.properties.bind===r.properties.bind:!e.properties&&!r.properties)},a=function(e){return{vnodeSelector:"",properties:void 0,children:void 0,text:e.toString(),domNode:null}},d=function(e,r,t){for(var o=0,n=r.length;o=0){for(p=f;pf)for(p=f;p=0){for(p=f;pf)for(p=f;p= 0) {\n // Remove preceding missing children\n for (i = oldIndex; i < findOldIndex; i++) {\n nodeToRemove(oldChildren[i], transitions);\n checkDistinguishable(oldChildren, i, vnode, 'removed');\n }\n textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions) || textUpdated;\n oldIndex = findOldIndex + 1;\n } else {\n // New child\n createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions);\n nodeAdded(newChild, transitions);\n checkDistinguishable(newChildren, newIndex, vnode, 'added');\n }\n }\n newIndex++;\n }\n if (oldChildrenLength > oldIndex) {\n // Remove child fragments\n for (i = oldIndex; i < oldChildrenLength; i++) {\n nodeToRemove(oldChildren[i], transitions);\n checkDistinguishable(oldChildren, i, vnode, 'removed');\n }\n }\n return textUpdated;\n };\n var addChildren = function (domNode, children, projectionOptions) {\n if (!children) {\n return;\n }\n for (var i = 0; i < children.length; i++) {\n createDom(children[i], domNode, undefined, projectionOptions);\n }\n };\n var initPropertiesAndChildren = function (domNode, vnode, projectionOptions) {\n addChildren(domNode, vnode.children, projectionOptions);\n // children before properties, needed for value property of .\n if (vnode.text) {\n domNode.textContent = vnode.text;\n }\n setProperties(domNode, vnode.properties, projectionOptions);\n if (vnode.properties && vnode.properties.afterCreate) {\n vnode.properties.afterCreate.apply(vnode.properties.bind || vnode.properties, [\n domNode,\n projectionOptions,\n vnode.vnodeSelector,\n vnode.properties,\n vnode.children\n ]);\n }\n };\n var insertNode = function (parentNode, domNode, vnode, beforeNode) {\n if (beforeNode) {\n parentNode.insertBefore(domNode, beforeNode);\n } else if (domNode.parentNode !== parentNode) {\n parentNode.appendChild(domNode);\n }\n };\n createDom = function (vnode, parentNode, insertBefore, projectionOptions) {\n var domNode, i, c, start = 0, type, found;\n var vnodeSelector = vnode.vnodeSelector;\n var delayAttach = false;\n var doc = parentNode.ownerDocument;\n if (vnodeSelector === '') {\n domNode = vnode.domNode = doc.createTextNode(vnode.text);\n insertNode(parentNode, domNode, vnode, insertBefore);\n } else {\n for (i = 0; i <= vnodeSelector.length; ++i) {\n c = vnodeSelector.charAt(i);\n if (i === vnodeSelector.length || c === '.' || c === '#') {\n type = vnodeSelector.charAt(start - 1);\n found = vnodeSelector.slice(start, i);\n if (type === '.') {\n domNode.classList.add(found);\n } else if (type === '#') {\n domNode.id = found;\n } else {\n if (found === 'svg') {\n projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG });\n }\n if (projectionOptions.namespace !== undefined) {\n domNode = vnode.domNode = doc.createElementNS(projectionOptions.namespace, found);\n } else {\n domNode = vnode.domNode = vnode.domNode || doc.createElement(found);\n delayAttach = domNode.nodeName.indexOf('-') !== -1;\n if (found === 'input' && vnode.properties && vnode.properties.type !== undefined) {\n // IE8 and older don't support setting input type after the DOM Node has been added to the document\n domNode.setAttribute('type', vnode.properties.type);\n }\n }\n if (!delayAttach) {\n insertNode(parentNode, domNode, vnode, insertBefore);\n }\n }\n start = i + 1;\n }\n }\n initPropertiesAndChildren(domNode, vnode, projectionOptions);\n if (delayAttach) {\n insertNode(parentNode, domNode, vnode, insertBefore);\n }\n }\n };\n updateDom = function (previous, vnode, projectionOptions) {\n var domNode = previous.domNode;\n var textUpdated = false;\n if (previous === vnode) {\n return false; // By contract, VNode objects may not be modified anymore after passing them to maquette\n }\n var updated = false;\n if (vnode.vnodeSelector === '') {\n if (vnode.text !== previous.text) {\n var newVNode = domNode.ownerDocument.createTextNode(vnode.text);\n domNode.parentNode.replaceChild(newVNode, domNode);\n vnode.domNode = newVNode;\n textUpdated = true;\n return textUpdated;\n }\n } else {\n if (vnode.vnodeSelector.lastIndexOf('svg', 0) === 0) {\n projectionOptions = extend(projectionOptions, { namespace: NAMESPACE_SVG });\n }\n if (previous.text !== vnode.text) {\n updated = true;\n if (vnode.text === undefined) {\n domNode.removeChild(domNode.firstChild); // the only textnode presumably\n } else {\n domNode.textContent = vnode.text;\n }\n }\n updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated;\n updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated;\n if (vnode.properties && vnode.properties.afterUpdate) {\n vnode.properties.afterUpdate.apply(vnode.properties.bind || vnode.properties, [\n domNode,\n projectionOptions,\n vnode.vnodeSelector,\n vnode.properties,\n vnode.children\n ]);\n }\n }\n if (updated && vnode.properties && vnode.properties.updateAnimation) {\n vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties);\n }\n vnode.domNode = previous.domNode;\n return textUpdated;\n };\n var createProjection = function (vnode, projectionOptions) {\n return {\n update: function (updatedVnode) {\n if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) {\n throw new Error('The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)');\n }\n updateDom(vnode, updatedVnode, projectionOptions);\n vnode = updatedVnode;\n },\n domNode: vnode.domNode\n };\n };\n // The other two parameters are not added here, because the Typescript compiler creates surrogate code for destructuring 'children'.\n exports.h = function (selector) {\n var properties = arguments[1];\n if (typeof selector !== 'string') {\n throw new Error();\n }\n var childIndex = 1;\n if (properties && !properties.hasOwnProperty('vnodeSelector') && !Array.isArray(properties) && typeof properties === 'object') {\n childIndex = 2;\n } else {\n // Optional properties argument was omitted\n properties = undefined;\n }\n var text;\n var children;\n var argsLength = arguments.length;\n // Recognize a common special case where there is only a single text node\n if (argsLength === childIndex + 1) {\n var onlyChild = arguments[childIndex];\n if (typeof onlyChild === 'string') {\n text = onlyChild;\n } else if (onlyChild !== undefined && onlyChild !== null && onlyChild.length === 1 && typeof onlyChild[0] === 'string') {\n text = onlyChild[0];\n }\n }\n if (text === undefined) {\n children = [];\n for (; childIndex < argsLength; childIndex++) {\n var child = arguments[childIndex];\n if (child === null || child === undefined) {\n } else if (Array.isArray(child)) {\n appendChildren(selector, child, children);\n } else if (child.hasOwnProperty('vnodeSelector')) {\n children.push(child);\n } else {\n children.push(toTextVNode(child));\n }\n }\n }\n return {\n vnodeSelector: selector,\n properties: properties,\n children: children,\n text: text === '' ? undefined : text,\n domNode: null\n };\n };\n /**\n * Contains simple low-level utility functions to manipulate the real DOM.\n */\n exports.dom = {\n /**\n * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in\n * its [[Projection.domNode|domNode]] property.\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection.\n * @returns The [[Projection]] which also contains the DOM Node that was created.\n */\n create: function (vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, document.createElement('div'), undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Appends a new child node to the DOM which is generated from a [[VNode]].\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param parentNode - The parent node for the new child node.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the [[Projection]].\n * @returns The [[Projection]] that was created.\n */\n append: function (parentNode, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, parentNode, undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Inserts a new DOM node which is generated from a [[VNode]].\n * This is a low-level method. Users wil typically use a [[Projector]] instead.\n * @param beforeNode - The node that the DOM Node is inserted before.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.\n * NOTE: [[VNode]] objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].\n * @returns The [[Projection]] that was created.\n */\n insertBefore: function (beforeNode, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.\n * This means that the virtual DOM and the real DOM will have one overlapping element.\n * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.\n * This is a low-level method. Users wil typically use a [[Projector]] instead.\n * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects\n * may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].\n * @returns The [[Projection]] that was created.\n */\n merge: function (element, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n vnode.domNode = element;\n initPropertiesAndChildren(element, vnode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n /**\n * Replaces an existing DOM node with a node generated from a [[VNode]].\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param element - The node for the [[VNode]] to replace.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the [[Projection]].\n * @returns The [[Projection]] that was created.\n */\n replace: function (element, vnode, projectionOptions) {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, element.parentNode, element, projectionOptions);\n element.parentNode.removeChild(element);\n return createProjection(vnode, projectionOptions);\n }\n };\n /**\n * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.\n * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.\n * For more information, see [[CalculationCache]].\n *\n * @param The type of the value that is cached.\n */\n exports.createCache = function () {\n var cachedInputs;\n var cachedOutcome;\n return {\n invalidate: function () {\n cachedOutcome = undefined;\n cachedInputs = undefined;\n },\n result: function (inputs, calculation) {\n if (cachedInputs) {\n for (var i = 0; i < inputs.length; i++) {\n if (cachedInputs[i] !== inputs[i]) {\n cachedOutcome = undefined;\n }\n }\n }\n if (!cachedOutcome) {\n cachedOutcome = calculation();\n cachedInputs = inputs;\n }\n return cachedOutcome;\n }\n };\n };\n /**\n * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects.\n * See {@link http://maquettejs.org/docs/arrays.html|Working with arrays}.\n *\n * @param The type of source items. A database-record for instance.\n * @param The type of target items. A [[Component]] for instance.\n * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number.\n * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical\n * to the `callback` argument in `Array.map(callback)`.\n * @param updateResult `function(source, target, index)` that updates a result to an updated source.\n */\n exports.createMapping = function (getSourceKey, createResult, updateResult) {\n var keys = [];\n var results = [];\n return {\n results: results,\n map: function (newSources) {\n var newKeys = newSources.map(getSourceKey);\n var oldTargets = results.slice();\n var oldIndex = 0;\n for (var i = 0; i < newSources.length; i++) {\n var source = newSources[i];\n var sourceKey = newKeys[i];\n if (sourceKey === keys[oldIndex]) {\n results[i] = oldTargets[oldIndex];\n updateResult(source, oldTargets[oldIndex], i);\n oldIndex++;\n } else {\n var found = false;\n for (var j = 1; j < keys.length + 1; j++) {\n var searchIndex = (oldIndex + j) % keys.length;\n if (keys[searchIndex] === sourceKey) {\n results[i] = oldTargets[searchIndex];\n updateResult(newSources[i], oldTargets[searchIndex], i);\n oldIndex = searchIndex + 1;\n found = true;\n break;\n }\n }\n if (!found) {\n results[i] = createResult(source, i);\n }\n }\n }\n results.length = newSources.length;\n keys = newKeys;\n }\n };\n };\n /**\n * Creates a [[Projector]] instance using the provided projectionOptions.\n *\n * For more information, see [[Projector]].\n *\n * @param projectorOptions Options that influence how the DOM is rendered and updated.\n */\n exports.createProjector = function (projectorOptions) {\n var projector;\n var projectionOptions = applyDefaultProjectionOptions(projectorOptions);\n projectionOptions.eventHandlerInterceptor = function (propertyName, eventHandler, domNode, properties) {\n return function () {\n // intercept function calls (event handlers) to do a render afterwards.\n projector.scheduleRender();\n return eventHandler.apply(properties.bind || this, arguments);\n };\n };\n var renderCompleted = true;\n var scheduled;\n var stopped = false;\n var projections = [];\n var renderFunctions = [];\n // matches the projections array\n var doRender = function () {\n scheduled = undefined;\n if (!renderCompleted) {\n return; // The last render threw an error, it should be logged in the browser console.\n }\n renderCompleted = false;\n for (var i = 0; i < projections.length; i++) {\n var updatedVnode = renderFunctions[i]();\n projections[i].update(updatedVnode);\n }\n renderCompleted = true;\n };\n projector = {\n renderNow: doRender,\n scheduleRender: function () {\n if (!scheduled && !stopped) {\n scheduled = requestAnimationFrame(doRender);\n }\n },\n stop: function () {\n if (scheduled) {\n cancelAnimationFrame(scheduled);\n scheduled = undefined;\n }\n stopped = true;\n },\n resume: function () {\n stopped = false;\n renderCompleted = true;\n projector.scheduleRender();\n },\n append: function (parentNode, renderMaquetteFunction) {\n projections.push(exports.dom.append(parentNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n insertBefore: function (beforeNode, renderMaquetteFunction) {\n projections.push(exports.dom.insertBefore(beforeNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n merge: function (domNode, renderMaquetteFunction) {\n projections.push(exports.dom.merge(domNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n replace: function (domNode, renderMaquetteFunction) {\n projections.push(exports.dom.replace(domNode, renderMaquetteFunction(), projectionOptions));\n renderFunctions.push(renderMaquetteFunction);\n },\n detach: function (renderMaquetteFunction) {\n for (var i = 0; i < renderFunctions.length; i++) {\n if (renderFunctions[i] === renderMaquetteFunction) {\n renderFunctions.splice(i, 1);\n return projections.splice(i, 1)[0];\n }\n }\n throw new Error('renderMaquetteFunction was not found');\n }\n };\n return projector;\n };\n}));",null]} \ No newline at end of file diff --git a/package.json b/package.json index bb65326..8b1666e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "animation", "transitions" ], - "version": "2.5.3", + "version": "2.5.4-pre.1", "author": "Johan Gorter ", "repository": { "type": "git", diff --git a/src/maquette.ts b/src/maquette.ts index d188678..2aca2cd 100644 --- a/src/maquette.ts +++ b/src/maquette.ts @@ -749,17 +749,22 @@ let initPropertiesAndChildren = function(domNode: Node, vnode: VNode, projection } }; +let insertNode = function (parentNode: Node, domNode: Node, vnode: VNode, beforeNode?: Node | null): void { + if (beforeNode) { + parentNode.insertBefore(domNode, beforeNode); + } else if (domNode.parentNode !== parentNode) { + parentNode.appendChild(domNode); + } +}; + createDom = function(vnode, parentNode, insertBefore, projectionOptions) { let domNode: Node | undefined, i: number, c: string, start = 0, type: string, found: string; let vnodeSelector = vnode.vnodeSelector; + let delayAttach = false; let doc = parentNode.ownerDocument; if (vnodeSelector === '') { domNode = vnode.domNode = doc.createTextNode(vnode.text!); - if (insertBefore !== undefined) { - parentNode.insertBefore(domNode, insertBefore); - } else { - parentNode.appendChild(domNode); - } + insertNode(parentNode, domNode, vnode, insertBefore); } else { for (i = 0; i <= vnodeSelector.length; ++i) { c = vnodeSelector.charAt(i); @@ -778,21 +783,24 @@ createDom = function(vnode, parentNode, insertBefore, projectionOptions) { domNode = vnode.domNode = doc.createElementNS(projectionOptions.namespace, found); } else { domNode = vnode.domNode = (vnode.domNode || doc.createElement(found)); + delayAttach = domNode.nodeName.indexOf('-') !== -1; if (found === 'input' && vnode.properties && vnode.properties.type !== undefined) { // IE8 and older don't support setting input type after the DOM Node has been added to the document - (domNode as Element).setAttribute("type", vnode.properties.type); + (domNode as Element).setAttribute('type', vnode.properties.type); } } - if (insertBefore !== undefined) { - parentNode.insertBefore(domNode, insertBefore); - } else if (domNode.parentNode !== parentNode) { - parentNode.appendChild(domNode); + if (!delayAttach) { + insertNode(parentNode, domNode, vnode, insertBefore); } } start = i + 1; } } initPropertiesAndChildren(domNode!, vnode, projectionOptions); + + if (delayAttach) { + insertNode(parentNode, domNode!, vnode, insertBefore); + } } }; diff --git a/test/dom/create.ts b/test/dom/create.ts index 2284005..7ea8c97 100644 --- a/test/dom/create.ts +++ b/test/dom/create.ts @@ -82,5 +82,11 @@ describe('dom', function() { expect(spy.called).to.be.false; }); + it('should delay attaching custom elements until after attribute and properties have been added', () => { + let projection = dom.create(h('custom-element', { + 'data-attr': 'attribute' + })); + expect(projection.domNode.outerHTML).to.equal(''); + }); }); });