${{user}}
`; - define: function define(intent, callback) { - if (intent.indexOf('-') < 0) { - if (!(intent in intents)) { - length = keys.push(intent); + for (var i = 1; i < minLen; i++) { + tresh[i] = currentEnd; + }var keymap = new Map$1(); + for (var _i = currentStart; _i < currentEnd; _i++) { + keymap.set(currentNodes[_i], _i); + }for (var _i2 = futureStart; _i2 < futureEnd; _i2++) { + var idxInOld = keymap.get(futureNodes[_i2]); + if (idxInOld != null) { + k = findK(tresh, minLen, idxInOld); + /* istanbul ignore else */ + if (-1 < k) { + tresh[k] = idxInOld; + link[k] = { + newi: _i2, + oldi: idxInOld, + prev: link[k - 1] + }; } - intents[intent] = callback; - } else { - attributes[intent] = callback; } - }, + } - // this method is used internally as last resort - // to retrieve a value out of an object - invoke: function invoke(object, callback) { - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (hasOwnProperty.call(object, key)) { - return intents[key](object[key], callback); - } + k = --minLen; + --currentEnd; + while (tresh[k] > currentEnd) { + --k; + }minLen = currentChanges + futureChanges - k; + var diff = Array(minLen); + var ptr = link[k]; + --futureEnd; + while (ptr) { + var _ptr = ptr, + newi = _ptr.newi, + oldi = _ptr.oldi; + + while (futureEnd > newi) { + diff[--minLen] = INSERTION; + --futureEnd; + } + while (currentEnd > oldi) { + diff[--minLen] = DELETION; + --currentEnd; } + diff[--minLen] = SKIP; + --futureEnd; + --currentEnd; + ptr = ptr.prev; + } + while (futureEnd >= futureStart) { + diff[--minLen] = INSERTION; + --futureEnd; + } + while (currentEnd >= currentStart) { + diff[--minLen] = DELETION; + --currentEnd; } + return diff; }; - // TODO: I'd love to code-cover RegExp too here - // these are fundamental for this library - - var spaces = ' \\f\\n\\r\\t'; - var almostEverything = '[^ ' + spaces + '\\/>"\'=]+'; - var attrName = '[ ' + spaces + ']+' + almostEverything; - var tagName = '<([A-Za-z]+[A-Za-z0-9:_-]*)((?:'; - var attrPartials = '(?:=(?:\'[^\']*?\'|"[^"]*?"|<[^>]*?>|' + almostEverything + '))?)'; - - var attrSeeker = new RegExp(tagName + attrName + attrPartials + '+)([ ' + spaces + ']*/?>)', 'g'); - - var selfClosing = new RegExp(tagName + attrName + attrPartials + '*)([ ' + spaces + ']*/>)', 'g'); + // this is pretty much the same petit-dom code without the delete map part + // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 + var OND = function OND(futureNodes, futureStart, rows, currentNodes, currentStart, cols, compare) { + var length = rows + cols; + var v = []; + var d = void 0, + k = void 0, + r = void 0, + c = void 0, + pv = void 0, + cv = void 0, + pd = void 0; + outer: for (d = 0; d <= length; d++) { + /* istanbul ignore if */ + if (d > SKIP_OND) return null; + pd = d - 1; + /* istanbul ignore next */ + pv = d ? v[d - 1] : [0, 0]; + cv = v[d] = []; + for (k = -d; k <= d; k += 2) { + if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { + c = pv[pd + k + 1]; + } else { + c = pv[pd + k - 1] + 1; + } + r = c - k; + while (c < cols && r < rows && compare(currentNodes[currentStart + c], futureNodes[futureStart + r])) { + c++; + r++; + } + if (c === cols && r === rows) { + break outer; + } + cv[d + k] = c; + } + } - // these are tiny helpers to simplify most common operations needed here - var create = function create(node, type) { - return doc(node).createElement(type); + var diff = Array(d / 2 + length / 2); + var diffIdx = diff.length - 1; + for (d = v.length - 1; d >= 0; d--) { + while (c > 0 && r > 0 && compare(currentNodes[currentStart + c - 1], futureNodes[futureStart + r - 1])) { + // diagonal edge = equality + diff[diffIdx--] = SKIP; + c--; + r--; + } + if (!d) break; + pd = d - 1; + /* istanbul ignore next */ + pv = d ? v[d - 1] : [0, 0]; + k = c - r; + if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { + // vertical edge = insertion + r--; + diff[diffIdx--] = INSERTION; + } else { + // horizontal edge = deletion + c--; + diff[diffIdx--] = DELETION; + } + } + return diff; }; - var doc = function doc(node) { - return node.ownerDocument || node; + + var applyDiff = function applyDiff(diff, get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before) { + var live = new Map$1(); + var length = diff.length; + var currentIndex = currentStart; + var i = 0; + while (i < length) { + switch (diff[i++]) { + case SKIP: + futureStart++; + currentIndex++; + break; + case INSERTION: + // TODO: bulk appends for sequential nodes + live.set(futureNodes[futureStart], 1); + append(get, parentNode, futureNodes, futureStart++, futureStart, currentIndex < currentLength ? get(currentNodes[currentIndex], 1) : before); + break; + case DELETION: + currentIndex++; + break; + } + } + i = 0; + while (i < length) { + switch (diff[i++]) { + case SKIP: + currentStart++; + break; + case DELETION: + // TODO: bulk removes for sequential nodes + if (live.has(currentNodes[currentStart])) currentStart++;else remove(get, parentNode, currentNodes, currentStart++, currentStart); + break; + } + } }; - var fragment = function fragment(node) { - return doc(node).createDocumentFragment(); + + var findK = function findK(ktr, length, j) { + var lo = 1; + var hi = length; + while (lo < hi) { + var mid = (lo + hi) / 2 >>> 0; + if (j < ktr[mid]) hi = mid;else lo = mid + 1; + } + return lo; }; - var text = function text(node, _text) { - return doc(node).createTextNode(_text); + + var smartDiff = function smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before) { + applyDiff(OND(futureNodes, futureStart, futureChanges, currentNodes, currentStart, currentChanges, compare) || HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges), get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before); }; - var testFragment = fragment(document); + /*! (c) 2018 Andrea Giammarchi (ISC) */ - // DOM4 node.append(...many) - var hasAppend = 'append' in testFragment; + var domdiff = function domdiff(parentNode, // where changes happen + currentNodes, // Array of current items/nodes + futureNodes, // Array of future items/nodes + options // optional object with one of the following properties + // before: domNode + // compare(generic, generic) => true if same generic + // node(generic) => Node + ) { + if (!options) options = {}; - // detect old browsers without HTMLTemplateElement content support - var hasContent = 'content' in create(document, 'template'); + var compare = options.compare || eqeq; + var get = options.node || identity; + var before = options.before == null ? null : get(options.before, 0); - // IE 11 has problems with cloning templates: it "forgets" empty childNodes - testFragment.appendChild(text(testFragment, 'g')); - testFragment.appendChild(text(testFragment, '')); - var hasDoomedCloneNode = testFragment.cloneNode(true).childNodes.length === 1; + var currentLength = currentNodes.length; + var currentEnd = currentLength; + var currentStart = 0; - // old browsers need to fallback to cloneNode - // Custom Elements V0 and V1 will work polyfilled - // but native implementations need importNode instead - // (specially Chromium and its old V0 implementation) - var hasImportNode = 'importNode' in document; + var futureEnd = futureNodes.length; + var futureStart = 0; - // appends an array of nodes - // to a generic node/fragment - // When available, uses append passing all arguments at once - // hoping that's somehow faster, even if append has more checks on type - var append = hasAppend ? function (node, childNodes) { - node.append.apply(node, childNodes); - } : function (node, childNodes) { - var length = childNodes.length; - for (var i = 0; i < length; i++) { - node.appendChild(childNodes[i]); + // common prefix + while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentStart], futureNodes[futureStart])) { + currentStart++; + futureStart++; } - }; - var findAttributes = new RegExp('(' + attrName + '=)([\'"]?)' + UIDC + '\\2', 'gi'); - var comments = function comments($0, $1, $2, $3) { - return '<' + $1 + $2.replace(findAttributes, replaceAttributes) + $3; - }; - var replaceAttributes = function replaceAttributes($0, $1, $2) { - return $1 + ($2 || '"') + UID + ($2 || '"'); - }; - - // given a node and a generic HTML content, - // create either an SVG or an HTML fragment - // where such content will be injected - var createFragment = function createFragment(node, html) { - return (OWNER_SVG_ELEMENT in node ? SVGFragment : HTMLFragment)(node, html.replace(attrSeeker, comments)); - }; - - // IE/Edge shenanigans proof cloneNode - // it goes through all nodes manually - // instead of relying the engine to suddenly - // merge nodes together - var cloneNode = hasDoomedCloneNode ? function (node) { - var clone = node.cloneNode(); - var childNodes = node.childNodes || - // this is an excess of caution - // but some node, in IE, might not - // have childNodes property. - // The following fallback ensure working code - // in older IE without compromising performance - // or any other browser/engine involved. - /* istanbul ignore next */ - []; - var length = childNodes.length; - for (var i = 0; i < length; i++) { - clone.appendChild(cloneNode(childNodes[i])); + // common suffix + while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1])) { + currentEnd--; + futureEnd--; } - return clone; - } : - // the following ignore is due code-coverage - // combination of not having document.importNode - // but having a working node.cloneNode. - // This shenario is common on older Android/WebKit browsers - // but basicHTML here tests just two major cases: - // with document.importNode or with broken cloneNode. - /* istanbul ignore next */ - function (node) { - return node.cloneNode(true); - }; - - // used to import html into fragments - var importNode = hasImportNode ? function (doc$$1, node) { - return doc$$1.importNode(node, true); - } : function (doc$$1, node) { - return cloneNode(node); - }; - - // just recycling a one-off array to use slice - // in every needed place - var slice = [].slice; - // lazy evaluated, returns the unique identity - // of a template literal, as tempalte literal itself. - // By default, ES2015 template literals are unique - // tag`a${1}z` === tag`a${2}z` - // even if interpolated values are different - // the template chunks are in a frozen Array - // that is identical each time you use the same - // literal to represent same static content - // around its own interpolations. - var unique = function unique(template) { - return _TL(template); - }; + var currentSame = currentStart === currentEnd; + var futureSame = futureStart === futureEnd; - // https://codepen.io/WebReflection/pen/dqZrpV?editors=0010 - // TL returns a unique version of the template - // it needs lazy feature detection - // (cannot trust literals with transpiled code) - var _TL = function TL(t) { - if ( - // TypeScript template literals are not standard - t.propertyIsEnumerable('raw') || !Object.isFrozen(t.raw) || - // Firefox < 55 has not standard implementation neither - /Firefox\/(\d+)/.test((G.navigator || {}).userAgent) && parseFloat(RegExp.$1) < 55) { - var T = {}; - _TL = function TL(t) { - var k = '^' + t.join('^'); - return T[k] || (T[k] = t); - }; - } else { - // make TL an identity like function - _TL = function TL(t) { - return t; - }; - } - return _TL(t); - }; + // same list + if (currentSame && futureSame) return futureNodes; - // used to store templates objects - // since neither Map nor WeakMap are safe - var TemplateMap = function TemplateMap() { - try { - var wm = new WeakMap(); - var o_O = Object.freeze([]); - wm.set(o_O, true); - if (!wm.get(o_O)) throw o_O; - return wm; - } catch (o_O) { - // inevitable legacy code leaks due - // https://github.com/tc39/ecma262/pull/890 - return new Map$1(); + // only stuff to add + if (currentSame && futureStart < futureEnd) { + append(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentStart, currentLength, before)); + return futureNodes; } - }; - // create document fragments via native template - // with a fallback for browsers that won't be able - // to deal with some injected element suchsome ${'content'}
` - // hyperHTML finds only once per template literal, - // hence once per entire application life-cycle, - // all nodes that are related to interpolations. - // These nodes are stored as indexes used to retrieve, - // once per upgrade, nodes that will change on each future update. - // A path example is [2, 0, 1] representing the operation: - // node.childNodes[2].childNodes[0].childNodes[1] - // Attributes are addressed via their owner node and their name. - var createPath = function createPath(node) { - var path = []; - var parentNode = void 0; - switch (node.nodeType) { - case ELEMENT_NODE: - case DOCUMENT_FRAGMENT_NODE: - parentNode = node; - break; - case COMMENT_NODE: - parentNode = node.parentNode; - prepend(path, parentNode, node); - break; - default: - parentNode = node.ownerElement; - break; - } - for (node = parentNode; parentNode = parentNode.parentNode; node = parentNode) { - prepend(path, parentNode, node); + // the half match diff part has been skipped in petit-dom + // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 + // accordingly, I think it's safe to skip in here too + // if one day it'll come out like the speediest thing ever to do + // then I might add it in here too + + // Extra: before going too fancy, what about reversed lists ? + // This should bail out pretty quickly if that's not the case. + if (currentChanges === futureChanges && isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare)) { + append(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); + return futureNodes; } - return path; - }; - var prepend = function prepend(path, parent, node) { - path.unshift(path.indexOf.call(parent.childNodes, node)); - }; + // last resort through a smart diff + smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before); - var Path = { - create: function create(type, node, name) { - return { type: type, name: name, node: node, path: createPath(node) }; - }, - find: function find(node, path) { - var length = path.length; - for (var i = 0; i < length; i++) { - node = node.childNodes[path[i]]; - } - return node; - } + return futureNodes; }; - // from https://github.com/developit/preact/blob/33fc697ac11762a1cb6e71e9847670d047af7ce5/src/constants.js - var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; + /*! (c) Andrea Giammarchi - ISC */ + var self$3 = null || /* istanbul ignore next */{}; + try { + self$3.CustomEvent = new CustomEvent('.').constructor; + } catch (CustomEvent) { + self$3.CustomEvent = function CustomEvent(type, init) { + if (!init) init = {}; + var e = document.createEvent('Event'); + var bubbles = !!init.bubbles; + var cancelable = !!init.cancelable; + e.initEvent(type, bubbles, cancelable); + e.bubbles = bubbles; + e.cancelable = cancelable; + e.detail = init.detail; + return e; + }; + } + var CustomEvent$1 = self$3.CustomEvent; - // style is handled as both string and object - // even if the target is an SVG element (consistency) - var Style = (function (node, original, isSVG) { - if (isSVG) { - var style = original.cloneNode(true); - style.value = ''; - node.setAttributeNode(style); - return update(style, isSVG); - } - return update(node.style, isSVG); - }); + // hyperHTML.Component is a very basic class + // able to create Custom Elements like components + // including the ability to listen to connect/disconnect + // events via onconnect/ondisconnect attributes + // Components can be created imperatively or declaratively. + // The main difference is that declared components + // will not automatically render on setState(...) + // to simplify state handling on render. + function Component() { + return this; // this is needed in Edge !!! + } - // the update takes care or changing/replacing - // only properties that are different or - // in case of string, the whole node - var update = function update(style, isSVG) { - var oldType = void 0, - oldValue = void 0; - return function (newValue) { - switch (typeof newValue) { + // Component is lazily setup because it needs + // wire mechanism as lazy content + function setup(content) { + // there are various weakly referenced variables in here + // and mostly are to use Component.for(...) static method. + var children = new WeakMap$1(); + var create = Object.create; + var createEntry = function createEntry(wm, id, component) { + wm.set(id, component); + return component; + }; + var get = function get(Class, info, context, id) { + var relation = info.get(Class) || relate(Class, info); + switch (typeof id) { case 'object': - if (newValue) { - if (oldType === 'object') { - if (!isSVG) { - if (oldValue !== newValue) { - for (var key in oldValue) { - if (!(key in newValue)) { - style[key] = ''; - } - } - } - } - } else { - if (isSVG) style.value = '';else style.cssText = ''; - } - var info = isSVG ? {} : style; - for (var _key in newValue) { - var value = newValue[_key]; - var styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(_key) ? value + 'px' : value; - if (!isSVG && /^--/.test(_key)) info.setProperty(_key, styleValue);else info[_key] = styleValue; - } - oldType = 'object'; - if (isSVG) style.value = toStyle(oldValue = info);else oldValue = newValue; - break; - } + case 'function': + var wm = relation.w || (relation.w = new WeakMap$1()); + return wm.get(id) || createEntry(wm, id, new Class(context)); default: - if (oldValue != newValue) { - oldType = 'string'; - oldValue = newValue; - if (isSVG) style.value = newValue || '';else style.cssText = newValue || ''; + var sm = relation.p || (relation.p = create(null)); + return sm[id] || (sm[id] = new Class(context)); + } + }; + var relate = function relate(Class, info) { + var relation = { w: null, p: null }; + info.set(Class, relation); + return relation; + }; + var set = function set(context) { + var info = new Map$1(); + children.set(context, info); + return info; + }; + // The Component Class + Object.defineProperties(Component, { + // Component.for(context[, id]) is a convenient way + // to automatically relate data/context to children components + // If not created yet, the new Component(context) is weakly stored + // and after that same instance would always be returned. + for: { + configurable: true, + value: function value(context, id) { + return get(this, children.get(context) || set(context), context, id == null ? 'default' : id); + } + } + }); + Object.defineProperties(Component.prototype, { + // all events are handled with the component as context + handleEvent: { + value: function value(e) { + var ct = e.currentTarget; + this['getAttribute' in ct && ct.getAttribute('data-call') || 'on' + e.type](e); + } + }, + // components will lazily define html or svg properties + // as soon as these are invoked within the .render() method + // Such render() method is not provided by the base class + // but it must be available through the Component extend. + // Declared components could implement a + // render(props) method too and use props as needed. + html: lazyGetter('html', content), + svg: lazyGetter('svg', content), + // the state is a very basic/simple mechanism inspired by Preact + state: lazyGetter('state', function () { + return this.defaultState; + }), + // it is possible to define a default state that'd be always an object otherwise + defaultState: { + get: function get() { + return {}; + } + }, + // dispatch a bubbling, cancelable, custom event + // through the first known/available node + dispatch: { + value: function value(type, detail) { + var _wire$ = this._wire$; + + if (_wire$) { + var event = new CustomEvent$1(type, { + bubbles: true, + cancelable: true, + detail: detail + }); + event.component = this; + return (_wire$.dispatchEvent ? _wire$ : _wire$.childNodes[0]).dispatchEvent(event); } - break; + return false; + } + }, + // setting some property state through a new object + // or a callback, triggers also automatically a render + // unless explicitly specified to not do so (render === false) + setState: { + value: function value(state, render) { + var target = this.state; + var source = typeof state === 'function' ? state.call(this, target) : state; + for (var key in source) { + target[key] = source[key]; + }if (render !== false) this.render(); + return this; + } + } + }); + } + + // instead of a secret key I could've used a WeakMap + // However, attaching a property directly will result + // into better performance with thousands of components + // hanging around, and less memory pressure caused by the WeakMap + var lazyGetter = function lazyGetter(type, fn) { + var secret = '_' + type + '$'; + return { + get: function get() { + return this[secret] || setValue(this, secret, fn.call(this, type)); + }, + set: function set(value) { + setValue(this, secret, value); } }; }; - var hyphen = /([^A-Z])([A-Z]+)/g; - var ized = function ized($0, $1, $2) { - return $1 + '-' + $2.toLowerCase(); - }; - var toStyle = function toStyle(object) { - var css = []; - for (var key in object) { - css.push(key.replace(hyphen, ized), ':', object[key], ';'); - } - return css.join(''); + // shortcut to set value on get or set(value) + var setValue = function setValue(self, secret, value) { + return Object.defineProperty(self, secret, { + configurable: true, + value: typeof value === 'function' ? function () { + return self._wire$ = value.apply(this, arguments); + } : value + })[secret]; }; - /* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ - var append$1 = function append(get, parent, children, start, end, before) { - if (end - start < 2) parent.insertBefore(get(children[start], 1), before);else { - var fragment = parent.ownerDocument.createDocumentFragment(); - while (start < end) { - fragment.appendChild(get(children[start++], 1)); - }parent.insertBefore(fragment, before); - } - }; + var attributes = {}; + var intents = {}; + var keys = []; + var hasOwnProperty = intents.hasOwnProperty; - var eqeq = function eqeq(a, b) { - return a == b; - }; + var length = 0; - var identity = function identity(O) { - return O; - }; + var Intent = { - var indexOf = function indexOf(moreNodes, moreStart, moreEnd, lessNodes, lessStart, lessEnd, compare) { - var length = lessEnd - lessStart; - /* istanbul ignore if */ - if (length < 1) return -1; - while (moreEnd - moreStart >= length) { - var m = moreStart; - var l = lessStart; - while (m < moreEnd && l < lessEnd && compare(moreNodes[m], lessNodes[l])) { - m++; - l++; + // used to invoke right away hyper:attributes + attributes: attributes, + + // hyperHTML.define('intent', (object, update) => {...}) + // can be used to define a third parts update mechanism + // when every other known mechanism failed. + // hyper.define('user', info => info.name); + // hyper(node)`${{user}}
`; + define: function define(intent, callback) { + if (intent.indexOf('-') < 0) { + if (!(intent in intents)) { + length = keys.push(intent); + } + intents[intent] = callback; + } else { + attributes[intent] = callback; + } + }, + + // this method is used internally as last resort + // to retrieve a value out of an object + invoke: function invoke(object, callback) { + for (var i = 0; i < length; i++) { + var key = keys[i]; + if (hasOwnProperty.call(object, key)) { + return intents[key](object[key], callback); + } } - if (l === lessEnd) return moreStart; - moreStart = m + 1; } - return -1; }; - var isReversed = function isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare) { - while (currentStart < currentEnd && compare(currentNodes[currentStart], futureNodes[futureEnd - 1])) { - currentStart++; - futureEnd--; - } return futureEnd === 0; - }; + var isArray = Array.isArray || function (toString) { + var $ = toString.call([]); + return function isArray(object) { + return toString.call(object) === $; + }; + }({}.toString); - var next = function next(get, list, i, length, before) { - return i < length ? get(list[i], 0) : 0 < i ? get(list[i - 1], -0).nextSibling : before; + var trim = ''.trim || function () { + return String(this).replace(/^\s+|\s+/g, ''); }; - var remove = function remove(get, parent, children, start, end) { - if (end - start < 2) parent.removeChild(get(children[start], -1));else { - var range = parent.ownerDocument.createRange(); - range.setStartBefore(get(children[start], -1)); - range.setEndAfter(get(children[end - 1], -1)); - range.deleteContents(); + /*! (c) Andrea Giammarchi */ + function disconnected(poly) { + + var CONNECTED = 'connected'; + var DISCONNECTED = 'dis' + CONNECTED; + var Event = poly.Event; + var WeakSet = poly.WeakSet; + var notObserving = true; + var observer = new WeakSet(); + return function observe(node) { + if (notObserving) { + notObserving = !notObserving; + startObserving(node.ownerDocument); + } + observer.add(node); + return node; + }; + function startObserving(document) { + var dispatched = null; + try { + new MutationObserver(changes).observe(document, { subtree: true, childList: true }); + } catch (o_O) { + var timer = 0; + var records = []; + var reschedule = function reschedule(record) { + records.push(record); + clearTimeout(timer); + timer = setTimeout(function () { + changes(records.splice(timer = 0, records.length)); + }, 0); + }; + document.addEventListener('DOMNodeRemoved', function (event) { + reschedule({ addedNodes: [], removedNodes: [event.target] }); + }, true); + document.addEventListener('DOMNodeInserted', function (event) { + reschedule({ addedNodes: [event.target], removedNodes: [] }); + }, true); + } + function changes(records) { + dispatched = new Tracker(); + for (var record, length = records.length, i = 0; i < length; i++) { + record = records[i]; + dispatchAll(record.removedNodes, DISCONNECTED, CONNECTED); + dispatchAll(record.addedNodes, CONNECTED, DISCONNECTED); + } + dispatched = null; + } + function dispatchAll(nodes, type, counter) { + for (var node, event = new Event(type), length = nodes.length, i = 0; i < length; (node = nodes[i++]).nodeType === 1 && dispatchTarget(node, event, type, counter)) {} + } + function dispatchTarget(node, event, type, counter) { + if (observer.has(node) && !dispatched[type].has(node)) { + dispatched[counter].delete(node); + dispatched[type].add(node); + node.dispatchEvent(event); + /* + // The event is not bubbling (perf reason: should it?), + // hence there's no way to know if + // stop/Immediate/Propagation() was called. + // Should DOM Level 0 work at all? + // I say it's a YAGNI case for the time being, + // and easy to implement in user-land. + if (!event.cancelBubble) { + var fn = node['on' + type]; + if (fn) + fn.call(node, event); + } + */ + } + for (var children = node.children, length = children.length, i = 0; i < length; dispatchTarget(children[i++], event, type, counter)) {} + } + function Tracker() { + this[CONNECTED] = new WeakSet(); + this[DISCONNECTED] = new WeakSet(); + } } - }; + } - // - - - - - - - - - - - - - - - - - - - - // diff related constants and utilities - // - - - - - - - - - - - - - - - - - - - + var G = document.defaultView; - var DELETION = -1; - var INSERTION = 1; - var SKIP = 0; - var SKIP_OND = 50; + // Node.CONSTANTS + // 'cause some engine has no global Node defined + // (i.e. Node, NativeScript, basicHTML ... ) + var ELEMENT_NODE = 1; + var TEXT_NODE = 3; + var COMMENT_NODE = 8; + var DOCUMENT_FRAGMENT_NODE = 11; - /* istanbul ignore next */ - var Rel = typeof Map === 'undefined' ? function () { - var k = [], - v = []; - return { - has: function has(key) { - return -1 < k.indexOf(key); - }, - get: function get(key) { - return v[k.indexOf(key)]; - }, - set: function set(key, value) { - var i = k.indexOf(key); - v[i < 0 ? k.push(key) - 1 : i] = value; - } - }; - } : Map; + // HTML related constants + var VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i; - var HS = function HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges) { + // SVG related constants + var OWNER_SVG_ELEMENT = 'ownerSVGElement'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - var k = 0; - /* istanbul ignore next */ - var minLen = futureChanges < currentChanges ? futureChanges : currentChanges; - var link = Array(minLen++); - var tresh = Array(minLen); - tresh[0] = -1; + // Custom Elements / MutationObserver constants + var CONNECTED = 'connected'; + var DISCONNECTED = 'dis' + CONNECTED; - for (var i = 1; i < minLen; i++) { - tresh[i] = currentEnd; - }var keymap = new Rel(); - for (var _i = currentStart; _i < currentEnd; _i++) { - keymap.set(currentNodes[_i], _i); - }for (var _i2 = futureStart; _i2 < futureEnd; _i2++) { - var idxInOld = keymap.get(futureNodes[_i2]); - if (idxInOld != null) { - k = findK(tresh, minLen, idxInOld); - /* istanbul ignore else */ - if (-1 < k) { - tresh[k] = idxInOld; - link[k] = { - newi: _i2, - oldi: idxInOld, - prev: link[k - 1] - }; - } - } - } + // hyperHTML related constants + var EXPANDO = '_hyper: '; + var SHOULD_USE_TEXT_CONTENT = /^(?:style|textarea)$/i; + var UID = EXPANDO + (Math.random() * new Date() | 0) + ';'; + var UIDC = ''; - k = --minLen; - --currentEnd; - while (tresh[k] > currentEnd) { - --k; - }minLen = currentChanges + futureChanges - k; - var diff = Array(minLen); - var ptr = link[k]; - --futureEnd; - while (ptr) { - var _ptr = ptr, - newi = _ptr.newi, - oldi = _ptr.oldi; + // TODO: I'd love to code-cover RegExp too here + // these are fundamental for this library - while (futureEnd > newi) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd > oldi) { - diff[--minLen] = DELETION; - --currentEnd; - } - diff[--minLen] = SKIP; - --futureEnd; - --currentEnd; - ptr = ptr.prev; - } - while (futureEnd >= futureStart) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd >= currentStart) { - diff[--minLen] = DELETION; - --currentEnd; - } - return diff; - }; + var spaces = ' \\f\\n\\r\\t'; + var almostEverything = '[^ ' + spaces + '\\/>"\'=]+'; + var attrName = '[ ' + spaces + ']+' + almostEverything; + var tagName = '<([A-Za-z]+[A-Za-z0-9:_-]*)((?:'; + var attrPartials = '(?:=(?:\'[^\']*?\'|"[^"]*?"|<[^>]*?>|' + almostEverything + '))?)'; - // this is pretty much the same petit-dom code without the delete map part - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 - var OND = function OND(futureNodes, futureStart, rows, currentNodes, currentStart, cols, compare) { - var length = rows + cols; - var v = []; - var d = void 0, - k = void 0, - r = void 0, - c = void 0, - pv = void 0, - cv = void 0, - pd = void 0; - outer: for (d = 0; d <= length; d++) { - /* istanbul ignore if */ - if (d > SKIP_OND) return null; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - cv = v[d] = []; - for (k = -d; k <= d; k += 2) { - if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { - c = pv[pd + k + 1]; - } else { - c = pv[pd + k - 1] + 1; - } - r = c - k; - while (c < cols && r < rows && compare(currentNodes[currentStart + c], futureNodes[futureStart + r])) { - c++; - r++; - } - if (c === cols && r === rows) { - break outer; - } - cv[d + k] = c; - } - } + var attrSeeker = new RegExp(tagName + attrName + attrPartials + '+)([ ' + spaces + ']*/?>)', 'g'); - var diff = Array(d / 2 + length / 2); - var diffIdx = diff.length - 1; - for (d = v.length - 1; d >= 0; d--) { - while (c > 0 && r > 0 && compare(currentNodes[currentStart + c - 1], futureNodes[futureStart + r - 1])) { - // diagonal edge = equality - diff[diffIdx--] = SKIP; - c--; - r--; - } - if (!d) break; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - k = c - r; - if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { - // vertical edge = insertion - r--; - diff[diffIdx--] = INSERTION; - } else { - // horizontal edge = deletion - c--; - diff[diffIdx--] = DELETION; - } - } - return diff; + var selfClosing = new RegExp(tagName + attrName + attrPartials + '*)([ ' + spaces + ']*/>)', 'g'); + + // these are tiny helpers to simplify most common operations needed here + var create = function create(node, type) { + return doc(node).createElement(type); + }; + var doc = function doc(node) { + return node.ownerDocument || node; + }; + var fragment = function fragment(node) { + return doc(node).createDocumentFragment(); + }; + var text = function text(node, _text) { + return doc(node).createTextNode(_text); }; - var applyDiff = function applyDiff(diff, get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before) { - var live = new Rel(); - var length = diff.length; - var currentIndex = currentStart; - var i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - futureStart++; - currentIndex++; - break; - case INSERTION: - // TODO: bulk appends for sequential nodes - live.set(futureNodes[futureStart], 1); - append$1(get, parentNode, futureNodes, futureStart++, futureStart, currentIndex < currentLength ? get(currentNodes[currentIndex], 1) : before); - break; - case DELETION: - currentIndex++; - break; - } - } - i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - currentStart++; - break; - case DELETION: - // TODO: bulk removes for sequential nodes - if (live.has(currentNodes[currentStart])) currentStart++;else remove(get, parentNode, currentNodes, currentStart++, currentStart); - break; - } + var testFragment = fragment(document); + + // DOM4 node.append(...many) + var hasAppend = 'append' in testFragment; + + // detect old browsers without HTMLTemplateElement content support + var hasContent = 'content' in create(document, 'template'); + + // IE 11 has problems with cloning templates: it "forgets" empty childNodes + testFragment.appendChild(text(testFragment, 'g')); + testFragment.appendChild(text(testFragment, '')); + var hasDoomedCloneNode = testFragment.cloneNode(true).childNodes.length === 1; + + // old browsers need to fallback to cloneNode + // Custom Elements V0 and V1 will work polyfilled + // but native implementations need importNode instead + // (specially Chromium and its old V0 implementation) + var hasImportNode = 'importNode' in document; + + // appends an array of nodes + // to a generic node/fragment + // When available, uses append passing all arguments at once + // hoping that's somehow faster, even if append has more checks on type + var append$1 = hasAppend ? function (node, childNodes) { + node.append.apply(node, childNodes); + } : function (node, childNodes) { + var length = childNodes.length; + for (var i = 0; i < length; i++) { + node.appendChild(childNodes[i]); } }; - var findK = function findK(ktr, length, j) { - var lo = 1; - var hi = length; - while (lo < hi) { - var mid = (lo + hi) / 2 >>> 0; - if (j < ktr[mid]) hi = mid;else lo = mid + 1; - } - return lo; + var findAttributes = new RegExp('(' + attrName + '=)([\'"]?)' + UIDC + '\\2', 'gi'); + var comments = function comments($0, $1, $2, $3) { + return '<' + $1 + $2.replace(findAttributes, replaceAttributes) + $3; + }; + var replaceAttributes = function replaceAttributes($0, $1, $2) { + return $1 + ($2 || '"') + UID + ($2 || '"'); }; - var smartDiff = function smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before) { - applyDiff(OND(futureNodes, futureStart, futureChanges, currentNodes, currentStart, currentChanges, compare) || HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges), get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before); + // given a node and a generic HTML content, + // create either an SVG or an HTML fragment + // where such content will be injected + var createFragment = function createFragment(node, html) { + return (OWNER_SVG_ELEMENT in node ? SVGFragment : HTMLFragment)(node, html.replace(attrSeeker, comments)); }; - /* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ + // IE/Edge shenanigans proof cloneNode + // it goes through all nodes manually + // instead of relying the engine to suddenly + // merge nodes together + var cloneNode = hasDoomedCloneNode ? function (node) { + var clone = node.cloneNode(); + var childNodes = node.childNodes || + // this is an excess of caution + // but some node, in IE, might not + // have childNodes property. + // The following fallback ensure working code + // in older IE without compromising performance + // or any other browser/engine involved. + /* istanbul ignore next */ + []; + var length = childNodes.length; + for (var i = 0; i < length; i++) { + clone.appendChild(cloneNode(childNodes[i])); + } + return clone; + } : + // the following ignore is due code-coverage + // combination of not having document.importNode + // but having a working node.cloneNode. + // This shenario is common on older Android/WebKit browsers + // but basicHTML here tests just two major cases: + // with document.importNode or with broken cloneNode. + /* istanbul ignore next */ + function (node) { + return node.cloneNode(true); + }; - var domdiff = function domdiff(parentNode, // where changes happen - currentNodes, // Array of current items/nodes - futureNodes, // Array of future items/nodes - options // optional object with one of the following properties - // before: domNode - // compare(generic, generic) => true if same generic - // node(generic) => Node - ) { - if (!options) options = {}; + // used to import html into fragments + var importNode = hasImportNode ? function (doc$$1, node) { + return doc$$1.importNode(node, true); + } : function (doc$$1, node) { + return cloneNode(node); + }; - var compare = options.compare || eqeq; - var get = options.node || identity; - var before = options.before == null ? null : get(options.before, 0); + // just recycling a one-off array to use slice + // in every needed place + var slice = [].slice; - var currentLength = currentNodes.length; - var currentEnd = currentLength; - var currentStart = 0; + // lazy evaluated, returns the unique identity + // of a template literal, as tempalte literal itself. + // By default, ES2015 template literals are unique + // tag`a${1}z` === tag`a${2}z` + // even if interpolated values are different + // the template chunks are in a frozen Array + // that is identical each time you use the same + // literal to represent same static content + // around its own interpolations. + var unique = function unique(template) { + return _TL(template); + }; - var futureEnd = futureNodes.length; - var futureStart = 0; + // https://codepen.io/WebReflection/pen/dqZrpV?editors=0010 + // TL returns a unique version of the template + // it needs lazy feature detection + // (cannot trust literals with transpiled code) + var _TL = function TL(t) { + if ( + // TypeScript template literals are not standard + t.propertyIsEnumerable('raw') || !Object.isFrozen(t.raw) || + // Firefox < 55 has not standard implementation neither + /Firefox\/(\d+)/.test((G.navigator || {}).userAgent) && parseFloat(RegExp.$1) < 55) { + var T = {}; + _TL = function TL(t) { + var k = '^' + t.join('^'); + return T[k] || (T[k] = t); + }; + } else { + // make TL an identity like function + _TL = function TL(t) { + return t; + }; + } + return _TL(t); + }; - // common prefix - while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentStart], futureNodes[futureStart])) { - currentStart++; - futureStart++; + // used to store templates objects + // since neither Map nor WeakMap are safe + var TemplateMap = function TemplateMap() { + try { + var wm = new WeakMap$1(); + var o_O = Object.freeze([]); + wm.set(o_O, true); + if (!wm.get(o_O)) throw o_O; + return wm; + } catch (o_O) { + // inevitable legacy code leaks due + // https://github.com/tc39/ecma262/pull/890 + return new Map$1(); } + }; - // common suffix - while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1])) { - currentEnd--; - futureEnd--; + // create document fragments via native template + // with a fallback for browsers that won't be able + // to deal with some injected element suchsome ${'content'}
` + // hyperHTML finds only once per template literal, + // hence once per entire application life-cycle, + // all nodes that are related to interpolations. + // These nodes are stored as indexes used to retrieve, + // once per upgrade, nodes that will change on each future update. + // A path example is [2, 0, 1] representing the operation: + // node.childNodes[2].childNodes[0].childNodes[1] + // Attributes are addressed via their owner node and their name. + var createPath = function createPath(node) { + var path = []; + var parentNode = void 0; + switch (node.nodeType) { + case ELEMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: + parentNode = node; + break; + case COMMENT_NODE: + parentNode = node.parentNode; + prepend(path, parentNode, node); + break; + default: + parentNode = node.ownerElement; + break; + } + for (node = parentNode; parentNode = parentNode.parentNode; node = parentNode) { + prepend(path, parentNode, node); } + return path; + }; - var currentChanges = currentEnd - currentStart; - var futureChanges = futureEnd - futureStart; - var i = -1; + var prepend = function prepend(path, parent, node) { + path.unshift(path.indexOf.call(parent.childNodes, node)); + }; - // 2 simple indels: the shortest sequence is a subsequence of the longest - if (currentChanges < futureChanges) { - i = indexOf(futureNodes, futureStart, futureEnd, currentNodes, currentStart, currentEnd, compare); - // inner diff - if (-1 < i) { - append$1(get, parentNode, futureNodes, futureStart, i, get(currentNodes[currentStart], 0)); - append$1(get, parentNode, futureNodes, i + currentChanges, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); - return futureNodes; - } - } - /* istanbul ignore else */ - else if (futureChanges < currentChanges) { - i = indexOf(currentNodes, currentStart, currentEnd, futureNodes, futureStart, futureEnd, compare); - // outer diff - if (-1 < i) { - remove(get, parentNode, currentNodes, currentStart, i); - remove(get, parentNode, currentNodes, i + futureChanges, currentEnd); - return futureNodes; - } + var Path = { + create: function create(type, node, name) { + return { type: type, name: name, node: node, path: createPath(node) }; + }, + find: function find(node, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + node = node.childNodes[path[i]]; } - - // common case with one replacement for many nodes - // or many nodes replaced for a single one - /* istanbul ignore else */ - if (currentChanges < 2 || futureChanges < 2) { - append$1(get, parentNode, futureNodes, futureStart, futureEnd, get(currentNodes[currentStart], 0)); - remove(get, parentNode, currentNodes, currentStart, currentEnd); - return futureNodes; + return node; } + }; - // the half match diff part has been skipped in petit-dom - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 - // accordingly, I think it's safe to skip in here too - // if one day it'll come out like the speediest thing ever to do - // then I might add it in here too + // from https://github.com/developit/preact/blob/33fc697ac11762a1cb6e71e9847670d047af7ce5/src/constants.js + var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; - // Extra: before going too fancy, what about reversed lists ? - // This should bail out pretty quickly if that's not the case. - if (currentChanges === futureChanges && isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare)) { - append$1(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); - return futureNodes; + // style is handled as both string and object + // even if the target is an SVG element (consistency) + var Style = (function (node, original, isSVG) { + if (isSVG) { + var style = original.cloneNode(true); + style.value = ''; + node.setAttributeNode(style); + return update(style, isSVG); } + return update(node.style, isSVG); + }); - // last resort through a smart diff - smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before); - - return futureNodes; - }; - - /* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ - /*! (c) Andrea Giammarchi */ - function disconnected(poly) { - - var CONNECTED = 'connected'; - var DISCONNECTED = 'dis' + CONNECTED; - var Event = poly.Event; - var WeakSet = poly.WeakSet; - var notObserving = true; - var observer = new WeakSet(); - return function observe(node) { - if (notObserving) { - notObserving = !notObserving; - startObserving(node.ownerDocument); - } - observer.add(node); - return node; - }; - function startObserving(document) { - var dispatched = null; - try { - new MutationObserver(changes).observe(document, { subtree: true, childList: true }); - } catch (o_O) { - var timer = 0; - var records = []; - var reschedule = function reschedule(record) { - records.push(record); - clearTimeout(timer); - timer = setTimeout(function () { - changes(records.splice(timer = 0, records.length)); - }, 0); - }; - document.addEventListener('DOMNodeRemoved', function (event) { - reschedule({ addedNodes: [], removedNodes: [event.target] }); - }, true); - document.addEventListener('DOMNodeInserted', function (event) { - reschedule({ addedNodes: [event.target], removedNodes: [] }); - }, true); - } - function changes(records) { - dispatched = new Tracker(); - for (var record, length = records.length, i = 0; i < length; i++) { - record = records[i]; - dispatchAll(record.removedNodes, DISCONNECTED, CONNECTED); - dispatchAll(record.addedNodes, CONNECTED, DISCONNECTED); - } - dispatched = null; - } - function dispatchAll(nodes, type, counter) { - for (var node, event = new Event(type), length = nodes.length, i = 0; i < length; (node = nodes[i++]).nodeType === 1 && dispatchTarget(node, event, type, counter)) {} - } - function dispatchTarget(node, event, type, counter) { - if (observer.has(node) && !dispatched[type].has(node)) { - dispatched[counter].delete(node); - dispatched[type].add(node); - node.dispatchEvent(event); - /* - // The event is not bubbling (perf reason: should it?), - // hence there's no way to know if - // stop/Immediate/Propagation() was called. - // Should DOM Level 0 work at all? - // I say it's a YAGNI case for the time being, - // and easy to implement in user-land. - if (!event.cancelBubble) { - var fn = node['on' + type]; - if (fn) - fn.call(node, event); + // the update takes care or changing/replacing + // only properties that are different or + // in case of string, the whole node + var update = function update(style, isSVG) { + var oldType = void 0, + oldValue = void 0; + return function (newValue) { + switch (typeof newValue) { + case 'object': + if (newValue) { + if (oldType === 'object') { + if (!isSVG) { + if (oldValue !== newValue) { + for (var key in oldValue) { + if (!(key in newValue)) { + style[key] = ''; + } + } + } + } + } else { + if (isSVG) style.value = '';else style.cssText = ''; + } + var info = isSVG ? {} : style; + for (var _key in newValue) { + var value = newValue[_key]; + var styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(_key) ? value + 'px' : value; + if (!isSVG && /^--/.test(_key)) info.setProperty(_key, styleValue);else info[_key] = styleValue; + } + oldType = 'object'; + if (isSVG) style.value = toStyle(oldValue = info);else oldValue = newValue; + break; } - */ - } - for (var children = node.children, length = children.length, i = 0; i < length; dispatchTarget(children[i++], event, type, counter)) {} - } - function Tracker() { - this[CONNECTED] = new WeakSet(); - this[DISCONNECTED] = new WeakSet(); + default: + if (oldValue != newValue) { + oldType = 'string'; + oldValue = newValue; + if (isSVG) style.value = newValue || '';else style.cssText = newValue || ''; + } + break; } + }; + }; + + var hyphen = /([^A-Z])([A-Z]+)/g; + var ized = function ized($0, $1, $2) { + return $1 + '-' + $2.toLowerCase(); + }; + var toStyle = function toStyle(object) { + var css = []; + for (var key in object) { + css.push(key.replace(hyphen, ized), ':', object[key], ';'); } - } + return css.join(''); + }; var document$1 = G.document; - var observe = disconnected({ Event: Event, WeakSet: WeakSet }); + var observe = disconnected({ Event: CustomEvent$1, WeakSet: WeakSet$1 }); // a basic dictionary used to filter already cached attributes // while looking for special hyperHTML values. @@ -1501,7 +1532,7 @@ var hyperHTML = (function (global) { // a weak collection of contexts that // are already known to hyperHTML - var bewitched = new WeakMap(); + var bewitched = new WeakMap$1(); // all unique template literals var templates = TemplateMap(); @@ -1565,7 +1596,7 @@ var hyperHTML = (function (global) { }; // all wires used per each context - var wires = new WeakMap(); + var wires = new WeakMap$1(); // A wire is a callback used as tag function // to lazily relate a generic object to a template literal. @@ -1604,7 +1635,7 @@ var hyperHTML = (function (global) { updates.apply(null, arguments); if (setup) { if (type === 'svg') { - append(content, slice.call(container.childNodes)); + append$1(content, slice.call(container.childNodes)); } wire = wireContent(content); } @@ -1675,8 +1706,8 @@ var hyperHTML = (function (global) { // i.e. those still targeting IE hyper._ = { global: G, - WeakMap: WeakMap, - WeakSet: WeakSet + WeakMap: WeakMap$1, + WeakSet: WeakSet$1 }; // the wire content is the lazy defined diff --git a/min.js b/min.js index ee9dc0d9..11204346 100644 --- a/min.js +++ b/min.js @@ -1,2 +1,3 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t', '
'], ['', '
']), _templateObject36 = _taggedTemplateLiteral([''], ['']), _templateObject37 = _taggedTemplateLiteral([''], ['']), - _templateObject38 = _taggedTemplateLiteral([''], ['']), + _templateObject38 = _taggedTemplateLiteral([''], ['']), _templateObject39 = _taggedTemplateLiteral([' is defined');
p.render().click();
tressa.assert(p.clicked, 'the event worked');
- render(_templateObject11, [Rect.for({ x: 789, y: 123 })]);
+ render(_templateObject11, [hyperHTML.Component.for.call(Rect, { x: 789, y: 123 })]);
tressa.assert(div.querySelector('rect').getAttribute('x') == '789', 'the for(state) worked');
}).then(function () {
return tressa.async(function (done) {
@@ -1115,7 +1123,7 @@ tressa.async(function (done) {
tressa.assert(div.children[2].getAttribute('test') == "2", 'third node ok');
div = hyperHTML.wire()(_templateObject66);
tressa.assert(div.children.length === 1, 'one svg');
- tressa.assert(div.children[0].children.length === 2, 'two paths');
+ tressa.assert(div.querySelectorAll('path').length === 2, 'two paths');
}).then(function () {
tressa.log('##