diff --git a/README.md b/README.md
index 7f4a330..fa1aaad 100644
--- a/README.md
+++ b/README.md
@@ -111,14 +111,15 @@ class App extends Keet {
const app = new App()
app.mount(html`
-
+
one
two
-
three
+
four
+
+
five
`).link('app')
-
```
@@ -132,13 +133,13 @@ To map an array to elements use the ```{{model:}}{
```js
import Keet from 'keet'
-import { html, createModel } from 'keet/utils'
+import { html, createModel as CreateModel } from 'keet/utils'
-let task = new createModel()
+let task = new CreateModel()
class App extends Keet {
task = task
- componentWillMount(){
+ componentWillMount () {
// callBatchPoolUpdate - custom method to inform changes in the model.
// If the component has other states that reflect the model value changes
// we can safely ignore calling this method.
@@ -167,7 +168,7 @@ for (let i = 0; i < taskName.length; i++) {
app.task.add({
id: i,
taskName: taskName[i],
- complete: i % 2 === 0 ? false : true
+ complete: i % 2 !== 0
})
}
@@ -178,10 +179,7 @@ app.task.update('id', {
complete: true
})
-// remove a task
app.task.destroy('taskName', 'roll')
-
-console.log(app)
```
@@ -218,7 +216,7 @@ const app = new App()
app.mount(html`
parent
- {{component:subc}}
+
`).link('app')
diff --git a/examples/counter.js b/examples/counter.js
index 64588a5..1e61cd6 100644
--- a/examples/counter.js
+++ b/examples/counter.js
@@ -1,4 +1,4 @@
-/* global Event */
+/* global Event */ // rem
import Keet from '../'
import { html, getId } from '../utils'
diff --git a/examples/model.js b/examples/model.js
index 721fe47..2450a28 100644
--- a/examples/model.js
+++ b/examples/model.js
@@ -23,7 +23,7 @@ const app = new App()
let name = 'myModel' // rem
// rem
app.mount(html`
-
${name}
+
${name}
diff --git a/keet-min.js b/keet-min.js
index b6a8b88..e5a1eda 100644
--- a/keet-min.js
+++ b/keet-min.js
@@ -1,12 +1,12 @@
+
/**
- * Keetjs v4.0.0 Alpha release: https://github.com/keetjs/keet.js
- * Minimali4.0.0ew layer for the web
+ * Keetjs v4.0.0 Alpha release: https://github.com/keetjs/keet
+ * Minimalist view layer for the web
*
* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Keetjs >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*
* Copyright 2018, Shahrul Nizam Selamat
* Released under the MIT License.
*/
-
-var keet=function(){"use strict";function e(e){if(e.match(/([^?]*)\?([^:]*):([^;]*)|(\s*=\s*)[^;]*/g)){var t=e.split("?"),n=t[0],i=t[1].split(":")[0],o=t[1].split(":")[1];return!!this&&(this[n]?{value:E(i),state:n}:{value:E(o),state:n})}return!1}function t(e,t){"function"==typeof t&&t(e)}function n(e,t,n,i){t=t.replace(n,i),e&&(e.nodeValue=t)}function i(i,o,r,l,a,d){for(var c=i.match(M),s=c.length,u=void 0,f=void 0,h=void 0;s;)if(s--,u=c[s].replace(M,"$1"),f=e.call(r,u),h=I(u))t(u,l),n(o,i,"{{"+u+"}}",r[h[0]][h[1]]);else if(f){if(t(f.state,l),d)return f.value;n(o,i,"{{"+u+"}}",f.value)}else if(void 0!==r[u]){if(t(u,l),d)return r[u];n(o,i,"{{"+u+"}}",r[u])}}function o(e,t,n){var i=void 0,o=void 0,r=void 0,l=void 0,a=void 0,d=void 0,c=void 0,s=void 0,u=void 0,f=void 0,h=void 0,p=void 0,m=void 0,v=void 0,g=void 0,b=void 0;if(j[t]=j[t]||{},j[t].list||(j[t].list=e.nextSibling.cloneNode(!0)),m=j[t].list,j[t].str||(j[t].str=e.nextSibling.cloneNode(!0).outerHTML),v=j[t].str,j[t].ref||m.hasAttribute("id")&&m.id.match(B)&&(j[t].ref=m.id.replace(B,"$1"),e.nextSibling.remove(),b=this.__pristineFragment__.getElementById(m.id),b&&b.remove()),f=j[t].ref,void 0!==this[t]&&this[t].hasOwnProperty("list"))if(l=e.parentNode,H&&!l.hasAttribute("data-ignore")&&l.setAttribute("data-ignore",""),i=this[t].list,g=j[t].oldModel||[],H){c=L(i,g),s=L(g,i);var y=function(){for(var e=arguments.length,n=Array(e),o=0;o0&&0===s.length?c.map(function(e){a=V(v,e),d=H.createContextualFragment(a),u.insertBefore(d,u.lastChild)}):0===c.length&&s.length>0&&s.map(function(e){p=u.querySelector('[id="'+e[f]+'"]'),u.removeChild(p)}),j[t].oldModel=JSON.parse(JSON.stringify(i))};l.hasAttribute("id")&&(u=O(l.id),u?y.call(this,null,null,u):w({el:l.id},t,y.bind(this),function(){j[t].oldModel=[]}))}else for(o=0;o=0;)e.removeChild(N(e.lastChild))}function v(e){if(e.nodeType===ye){var t=e.getAttribute(f.KEY)||e.id;return t?ge+t:void 0}}function g(e,t){return y(e)&&y(t)||b(e)===b(t)||e.isEqualNode(t)}function b(e){return e.getAttribute(f.CHECKSUM)||NaN}function y(e){return null!=e.getAttribute(f.IGNORE)}function C(e){return S(e,"mount")}function N(e){return S(e,"dismount")}function S(e,t){if(v(e)){var n=document.createEvent("Event"),i={value:e};n.initEvent(t,!1,!1),Object.defineProperty(n,"target",i),Object.defineProperty(n,"srcElement",i),e.dispatchEvent(n)}for(var o=e.firstChild;o;)o=S(o,t).nextSibling;return e}function T(e,t){if(!e)throw Error("set-dom: "+t)}function A(e){c(this,Oe);var t=e||O(this.el);t?(t.nodeType===Fe?t.setAttribute("data-ignore",""):(F(1===this.base.childNodes.length,"Sub-component should only has a single rootNode."),!this.base.firstChild.hasAttribute("data-ignore")&&this.base.firstChild.setAttribute("data-ignore","")),_e.call(this),e||t.appendChild(this.base),this.componentDidMount&&"function"==typeof this.componentDidMount&&this.componentDidMount()):F(!1,'No element with id: "'+this.el+'" exist.')}function x(e){var t=void 0,n=void 0,i=document.createDocumentFragment();if("string"==typeof e)for(t=e.trim().replace(/\s+/g," "),n=document.createElement("div"),n.innerHTML=t;n.firstChild;)i.appendChild(n.firstChild);else"object"===(void 0===e?"undefined":_(e))&&e.nodeType?e.nodeType===Ve?i.appendChild(e):e.nodeType===Pe?i=e:e.nodeType===Ue?i.appendChild(e):assert(!1,"Unable to parse instance, unknown type."):assert(!1,"Parameter is not a string or a html element.");return this.__pristineFragment__=i.cloneNode(!0),this.base=i,ke(),this}var E=function(e){return"''"===e||'""'===e||"null"===e?"":e},I=function(e){var t=e.match(/\.*\./g);return t&&t.length>0?e.split("."):void 0},M=/{{([^{}]+)}}/g,_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D=function(){function e(e,t){for(var n=0;n';try{var se=ne.parseFromString(ce,le).body.firstChild,ue=document.createElement("div");if(ue.appendChild(se),ue.firstChild.classList[0]!==de)throw Error();oe=!0}catch(e){}var fe=document.implementation.createHTMLDocument(""),he=fe.documentElement,pe=fe.body;try{he.innerHTML+="",re=!0}catch(e){ne.parseFromString(ce,ae);var me=/(]*>)([\s\S]*)<\/body>/}var ve=oe?s:u;f.KEY="data-key",f.IGNORE="data-ignore",f.CHECKSUM="data-checksum";var ge="_set-dom-",be=ge+"mounted",ye=1,Ce=9,Ne=11,Se=f,Te=1,Ae=void 0,xe=function(){Ae=O(this.el),we.call(this),Ae&&(this.IS_STUB?Se(Ae,this.base.firstChild):Se(Ae,this.base)),this.componentDidUpdate&&"function"==typeof this.componentDidUpdate&&this.componentDidUpdate()},Ee={},Ie=function(e,t){var n=this;Ee[this.ID]=Ee[this.ID]||null,clearTimeout(Ee[this.ID]),Ee[this.ID]=setTimeout(function(){return e.call(n)},t)},Me=function e(t){var n=void 0,i=void 0;if(t0&&0===s.length)for(o=0;o0)for(o=0;o0&&s.length>0){for(o=0;o0;)i--,o=g(n,i),r.appendChild(n[o])}var b=void 0,y=void 0,k=void 0;o?k=i:r?k=r.firstChild:(y=t.base,k=y.firstChild);var C=o||t,N=function(t){var e=t.attributes,i=0,o=void 0,r=void 0,l=void 0;for(i=e.length;i--;)o=e[i],l=o.localName,r=o.nodeValue,ot.test(l)?(t.removeAttribute(l),l=n(l,t,C,null,null,!0),t.setAttribute(l,r)):ot.test(r)&&(r=n(r,t,C,null,null,!0),"checked"===l?(t.checked=""!==r,t.removeAttribute(l)):""===r?t.setAttribute(l,""):t.setAttribute(l,r))},x=function(t){for(var e=t.attributes,i=0,n=void 0,o=void 0,r=void 0,l=void 0,a=void 0,d=[],u=void 0,s=void 0;i0?t.split("."):void 0},k=/{{([^{}]+)}}/g,C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N=function(){function t(t,e){for(var i=0;i str === '\\'\\'' || str === '\"\"' || str === 'null' ? '' : str\r\n\r\nexport default function (input) {\r\n if (input.match(/([^?]*)\\?([^:]*):([^;]*)|(\\s*=\\s*)[^;]*/g)) {\r\n let t = input.split('?')\r\n let condition = t[0]\r\n let leftHand = t[1].split(':')[0]\r\n let rightHand = t[1].split(':')[1]\r\n\r\n // check the condition fulfillment\r\n\r\n if(this){\r\n if (this[condition]) {\r\n return {\r\n value: test(leftHand),\r\n state: condition\r\n }\r\n } else {\r\n return {\r\n value: test(rightHand),\r\n state: condition\r\n }\r\n } \r\n }\r\n return false\r\n } else return false\r\n}\r\n","export default function (state, updateStateList) {\r\n if (typeof updateStateList === 'function') updateStateList(state)\r\n}\r\n","export default function (node, value, replace, withTo) {\r\n value = value.replace(replace, withTo)\r\n if (node) node.nodeValue = value\r\n}\r\n","import ternaryOps from '../ternaryOps'\r\nimport strInterpreter from '../strInterpreter'\r\nimport updateState from './updateState'\r\nimport valAssign from './valAssign'\r\n\r\nconst re = /{{([^{}]+)}}/g\r\n\r\nexport default function (value, node, ins, updateStateList, templateParse, isAttr) {\r\n const props = value.match(re)\r\n let ln = props.length\r\n let rep\r\n let tnr\r\n let isObjectNotation\r\n while (ln) {\r\n ln--\r\n rep = props[ln].replace(re, '$1')\r\n tnr = ternaryOps.call(ins, rep)\r\n isObjectNotation = strInterpreter(rep)\r\n if (isObjectNotation) {\r\n updateState(rep, updateStateList)\r\n valAssign(node, value, '{{' + rep + '}}', ins[isObjectNotation[0]][isObjectNotation[1]])\r\n } else {\r\n if (tnr) {\r\n updateState(tnr.state, updateStateList)\r\n if (!isAttr) {\r\n valAssign(node, value, '{{' + rep + '}}', tnr.value)\r\n } else {\r\n return tnr.value\r\n }\r\n } else {\r\n if (ins[rep] !== undefined) {\r\n updateState(rep, updateStateList)\r\n if (!isAttr) {\r\n valAssign(node, value, '{{' + rep + '}}', ins[rep])\r\n } else {\r\n return ins[rep]\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","import { assert, getId, checkNodeAvailability } from '../../utils'\r\nimport genModelTemplate from './genModelTemplate'\r\n\r\nconst re = /{{([^{}]+)}}/g\r\n\r\n// diffing two array of objects, including object properties differences\r\nconst diff = (fst, sec) =>\r\n fst.filter(obj =>\r\n !sec.some(inr => {\r\n let predicate = true\r\n for (let attr in inr) {\r\n if (obj[attr] !== inr[attr]) {\r\n predicate = false\r\n }\r\n }\r\n return predicate\r\n })\r\n )\r\n\r\n// check if browser support createRange\r\nlet range\r\nif (typeof document.createRange === 'function') {\r\n range = document.createRange()\r\n}\r\n\r\n// storage for model state\r\nlet cache = {}\r\n\r\nexport default function (node, model, tmplHandler) {\r\n let modelList\r\n let mLength\r\n let i\r\n let listClone\r\n let parentNode\r\n let m\r\n let documentFragment\r\n let updateOfNew\r\n let diffOfOld\r\n let pNode\r\n let ref\r\n let equalLength\r\n let child\r\n let list\r\n let str\r\n let oldModel\r\n let p\r\n\r\n cache[model] = cache[model] || {}\r\n\r\n if (!cache[model].list) {\r\n cache[model].list = node.nextSibling.cloneNode(true)\r\n }\r\n list = cache[model].list\r\n\r\n if (!cache[model].str) {\r\n cache[model].str = node.nextSibling.cloneNode(true).outerHTML\r\n }\r\n str = cache[model].str\r\n\r\n if (!cache[model].ref) {\r\n if (list.hasAttribute('id') && list.id.match(re)) {\r\n cache[model].ref = list.id.replace(re, '$1')\r\n // remove the first prototype node\r\n node.nextSibling.remove()\r\n // also remove from pristine node\r\n p = this.__pristineFragment__.getElementById(list.id)\r\n if (p) p.remove()\r\n }\r\n }\r\n ref = cache[model].ref\r\n\r\n if (this[model] !== undefined && this[model].hasOwnProperty('list')) {\r\n parentNode = node.parentNode\r\n\r\n if (range && !parentNode.hasAttribute('data-ignore')) {\r\n parentNode.setAttribute('data-ignore', '')\r\n }\r\n\r\n modelList = this[model].list\r\n\r\n oldModel = cache[model].oldModel || []\r\n\r\n // check if current browser doesn't support createRange()\r\n if (!range) {\r\n i = 0\r\n while (i < mLength) {\r\n // fallback to regular node generation handler\r\n listClone = list.cloneNode(true)\r\n tmplHandler(this, null, listClone, modelList[i])\r\n i++\r\n }\r\n } else {\r\n updateOfNew = diff(modelList, oldModel)\r\n diffOfOld = diff(oldModel, modelList)\r\n\r\n const diffModel = function (...args) {\r\n pNode = args.pop()\r\n // check if both models are equally in length\r\n equalLength = oldModel.length === modelList.length\r\n\r\n // do properties update\r\n if (equalLength) {\r\n updateOfNew.map(obj => {\r\n child = pNode.querySelector(`[id=\"${obj[ref]}\"]`)\r\n m = genModelTemplate(str, obj)\r\n documentFragment = range.createContextualFragment(m)\r\n pNode.replaceChild(documentFragment, child)\r\n })\r\n // add new objects\r\n } else if (updateOfNew.length > 0 && diffOfOld.length === 0) {\r\n updateOfNew.map((obj) => {\r\n m = genModelTemplate(str, obj)\r\n documentFragment = range.createContextualFragment(m)\r\n pNode.insertBefore(documentFragment, pNode.lastChild)\r\n })\r\n // destroy selected objects\r\n } else if (updateOfNew.length === 0 && diffOfOld.length > 0) {\r\n diffOfOld.map(obj => {\r\n child = pNode.querySelector(`[id=\"${obj[ref]}\"]`)\r\n pNode.removeChild(child)\r\n })\r\n }\r\n // replace oldModel after diffing\r\n cache[model].oldModel = JSON.parse(JSON.stringify(modelList))\r\n }\r\n\r\n // check existing parentNode in the DOM\r\n if (parentNode.hasAttribute('id')) {\r\n pNode = getId(parentNode.id)\r\n\r\n if (pNode) {\r\n diffModel.call(this, null, null, pNode)\r\n } else {\r\n checkNodeAvailability({ el: parentNode.id }, model, diffModel.bind(this), function () {\r\n // we cleanup cache on failed search\r\n cache[model].oldModel = []\r\n })\r\n }\r\n }\r\n }\r\n } else {\r\n assert(false, 'Model \"' + model + '\" does not exist.')\r\n }\r\n}\r\n","const conditionalNodesRawStart = /\\{\\{\\?([^{}]+)\\}\\}/g\r\nconst conditionalNodesRawEnd = /\\{\\{\\/([^{}]+)\\}\\}/g\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\nexport default function (node, conditional, tmplHandler) {\r\n const frag = document.createDocumentFragment()\r\n let entryNode\r\n let currentNode\r\n let isGen\r\n let cNode\r\n while (node) {\r\n currentNode = node\r\n node = node.nextSibling\r\n if (currentNode.nodeType !== DOCUMENT_ELEMENT_TYPE) {\r\n if (currentNode.nodeValue.match(conditionalNodesRawStart)) {\r\n entryNode = currentNode\r\n } else if (currentNode.nodeValue.match(conditionalNodesRawEnd)) {\r\n currentNode.remove()\r\n // star generating the conditional nodes range, if not yet\r\n if (!isGen) {\r\n isGen = true\r\n tmplHandler(this, null, null, null, frag)\r\n }\r\n if (this[conditional]) {\r\n entryNode.parentNode.insertBefore(frag, entryNode)\r\n }\r\n entryNode.remove()\r\n node = null\r\n }\r\n } else {\r\n cNode = currentNode.cloneNode(true)\r\n frag.appendChild(cNode)\r\n currentNode.remove()\r\n }\r\n }\r\n}\r\n","import { assert, getId } from '../../utils'\r\n\r\nlet cacheInit = {}\r\n\r\nexport default function (componentStr, node) {\r\n const component = componentStr.replace('component:', '')\r\n const c = this[component]\r\n\r\n if (c !== undefined) {\r\n // this is for initial component runner\r\n if (!cacheInit[c.ID]) {\r\n c.render.call(c, true)\r\n cacheInit[c.ID] = c.base.cloneNode(true)\r\n node.parentNode.replaceChild(c.base, node)\r\n } else {\r\n // we need to reattach event listeners if the node is not available on DOM\r\n if (!getId(this[component].el)) {\r\n c.base = c.__pristineFragment__.cloneNode(true)\r\n c.render.call(c, true)\r\n node.parentNode.replaceChild(c.base, node)\r\n } else {\r\n node.parentNode.replaceChild(cacheInit[c.ID].cloneNode(true), node)\r\n }\r\n }\r\n // inform sub-component to update\r\n c.callBatchPoolUpdate()\r\n } else {\r\n assert(false, 'Component ' + component + ' does not exist.')\r\n }\r\n}\r\n","import genModelList from '../genModelList'\r\nimport conditionalNodes from '../conditionalNodes'\r\nimport updateState from './updateState'\r\nimport componentParse from '../componentParse'\r\n\r\nconst re = /{{([^{}]+)}}/g\r\nconst model = /^model:/g\r\nconst conditionalRe = /^\\?/g\r\nconst component = /^component:([^{}]+)/g\r\n\r\nexport default function (value, node, ins, updateStateList, templateParse) {\r\n let conditionalRep\r\n let rep\r\n let modelRep\r\n if (value.match(re)) {\r\n rep = value.replace(re, '$1').trim()\r\n if (rep.match(model)) {\r\n modelRep = rep.replace('model:', '')\r\n genModelList.call(this, node, modelRep, templateParse)\r\n } else if (rep.match(conditionalRe)) {\r\n conditionalRep = rep.replace('?', '')\r\n if (ins[conditionalRep] !== undefined) {\r\n updateState(conditionalRep, updateStateList)\r\n conditionalNodes.call(this, node, conditionalRep, templateParse)\r\n }\r\n } else if (rep.match(component)) {\r\n componentParse.call(this, rep, node)\r\n }\r\n }\r\n}\r\n","import { getId } from '../../../utils'\r\n\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\n\r\nconst modelRaw = /\\{\\{model:([^{}]+)\\}\\}/g\r\n\r\nconst lookUpEvtNode = node =>\r\n !!(node.hasAttribute('id') && getId(node.id) && node.hasAttribute('evt-node'))\r\n\r\nexport default function (node) {\r\n let nodeAttributes\r\n let i = 0\r\n let a\r\n let ns\r\n let evtName\r\n let c\r\n let h\r\n let handlerArgs\r\n let argv\r\n let handler\r\n let fn\r\n let name\r\n let p\r\n\r\n nodeAttributes = node.attributes\r\n if (lookUpEvtNode(node)) {\r\n // skip addding event for node that already has event\r\n // to allow skipping adding event the node must include `id`/\r\n } else {\r\n // only add event when node does not has one\r\n for (i = nodeAttributes.length; i--;) {\r\n a = nodeAttributes[i]\r\n name = a.localName\r\n ns = a.nodeValue\r\n if (/^k-/.test(name)) {\r\n evtName = name.replace(/^k-/, '')\r\n handler = ns.match(/[a-zA-Z]+(?![^(]*\\))/)[0]\r\n c = this[handler]\r\n if (c !== undefined && typeof c === 'function') {\r\n h = ns.match(/\\(([^{}]+)\\)/)\r\n handlerArgs = h ? h[1] : ''\r\n argv = handlerArgs.split(',').filter(function (f) {\r\n return f !== ''\r\n })\r\n fn = e => {\r\n e.stopPropagation()\r\n if (e.target !== e.currentTarget) {\r\n c.apply(this, [e.target, e])\r\n }\r\n }\r\n // if node is the rootNode for model, we wrap the eventListener and\r\n // rebuild the arguments by appending id/className util rootNode.\r\n if (node.hasChildNodes() && node.firstChild.nodeType !== DOCUMENT_ELEMENT_TYPE && node.firstChild.nodeValue.match(modelRaw)) {\r\n node.setAttribute('is-model-event-set', '')\r\n node.addEventListener(evtName, fn, false)\r\n } else {\r\n node.addEventListener(evtName, c.bind.apply(c.bind(this), [node].concat(argv)), false)\r\n }\r\n if (!node.hasAttribute('evt-node')) {\r\n node.setAttribute('evt-node', '')\r\n if (node.hasAttribute('id')) {\r\n p = this.__pristineFragment__.getElementById(node.id)\r\n p.setAttribute('evt-node', '')\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","import replaceHandleBars from './replaceHandleBars'\r\nimport replaceCommentBlock from './replaceCommentBlock'\r\nimport addEvent from './addEvent'\r\n\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\nconst DOCUMENT_COMMENT_TYPE = 8\r\nconst re = /{{([^{}]+)}}/g\r\n\r\nfunction templateParse (ctx, updateStateList, modelInstance, modelObject, conditional) {\r\n \r\n let currentNode\r\n let fragment\r\n let instance\r\n let nodeAttributes\r\n let i = 0\r\n let a\r\n let ns\r\n let name\r\n\r\n if (modelObject) {\r\n instance = modelInstance\r\n } else if (conditional) {\r\n instance = conditional.firstChild\r\n } else {\r\n fragment = ctx.base\r\n instance = fragment.firstChild\r\n }\r\n\r\n let ins = modelObject || ctx\r\n\r\n const inspectAttributes = node => {\r\n nodeAttributes = node.attributes\r\n for (i = nodeAttributes.length; i--;) {\r\n a = nodeAttributes[i]\r\n name = a.localName\r\n ns = a.nodeValue\r\n if (re.test(name)) {\r\n node.removeAttribute(name)\r\n name = replaceHandleBars(name, node, ins, null, null, true)\r\n node.setAttribute(name, ns)\r\n } else if (re.test(ns)) {\r\n ns = replaceHandleBars(ns, node, ins, null, null, true)\r\n if (ns === '') {\r\n node.removeAttribute(name)\r\n } else {\r\n if (name === 'checked') {\r\n node.setAttribute(name, '')\r\n } else {\r\n node.setAttribute(name, ns)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n const check = node => {\r\n while (node) {\r\n currentNode = node\r\n if (currentNode.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n if (currentNode.hasAttributes()) {\r\n addEvent.call(ctx, currentNode)\r\n inspectAttributes(currentNode)\r\n }\r\n check(currentNode.firstChild)\r\n } else if (currentNode.nodeValue.match(re)) {\r\n if (currentNode.nodeType === DOCUMENT_COMMENT_TYPE) {\r\n replaceCommentBlock.call(ctx, currentNode.nodeValue, currentNode, ins, updateStateList, templateParse)\r\n } else {\r\n replaceHandleBars.call(ctx, currentNode.nodeValue, currentNode, ins, updateStateList, templateParse)\r\n }\r\n }\r\n node = node.nextSibling\r\n }\r\n }\r\n\r\n check(instance)\r\n}\r\n\r\nexport default templateParse\r\n","'use strict'\nvar parser = window.DOMParser && new window.DOMParser()\nvar documentRootName = 'HTML'\nvar supportsHTMLType = false\nvar supportsInnerHTML = false\nvar htmlType = 'text/html'\nvar xhtmlType = 'application/xhtml+xml'\nvar testClass = 'A'\nvar testCode = ''\n\ntry {\n // Check if browser supports text/html DOMParser\n var parsed = parser.parseFromString(testCode, htmlType).body.firstChild\n // Some browsers (iOS 9 and Safari 9) lowercase classes for parsed elements\n // but only when appending to DOM, so use innerHTML instead\n var d = document.createElement('div')\n d.appendChild(parsed)\n if (d.firstChild.classList[0] !== testClass) throw new Error()\n supportsHTMLType = true\n} catch (e) {}\n\nvar mockDoc = document.implementation.createHTMLDocument('')\nvar mockHTML = mockDoc.documentElement\nvar mockBody = mockDoc.body\ntry {\n // Check if browser supports documentElement.innerHTML\n mockHTML.innerHTML += ''\n supportsInnerHTML = true\n} catch (e) {\n // Check if browser supports xhtml parsing.\n parser.parseFromString(testCode, xhtmlType)\n var bodyReg = /(]*>)([\\s\\S]*)<\\/body>/\n}\n\nfunction DOMParserParse (markup, rootName) {\n var doc = parser.parseFromString(markup, htmlType)\n // Patch for iOS UIWebView not always returning doc.body synchronously\n if (!doc.body) { return fallbackParse(markup, rootName) }\n\n return rootName === documentRootName\n ? doc.documentElement\n : doc.body.firstChild\n}\n\nfunction fallbackParse (markup, rootName) {\n // Fallback to innerHTML for other older browsers.\n if (rootName === documentRootName) {\n if (supportsInnerHTML) {\n mockHTML.innerHTML = markup\n return mockHTML\n } else {\n // IE9 does not support innerhtml at root level.\n // We get around this by parsing everything except the body as xhtml.\n var bodyMatch = markup.match(bodyReg)\n if (bodyMatch) {\n var bodyContent = bodyMatch[2]\n var startBody = bodyMatch.index + bodyMatch[1].length\n var endBody = startBody + bodyContent.length\n markup = markup.slice(0, startBody) + markup.slice(endBody)\n mockBody.innerHTML = bodyContent\n }\n\n var doc = parser.parseFromString(markup, xhtmlType)\n var body = doc.body\n while (mockBody.firstChild) body.appendChild(mockBody.firstChild)\n return doc.documentElement\n }\n } else {\n mockBody.innerHTML = markup\n return mockBody.firstChild\n }\n}\n\n/**\n * Returns the results of a DOMParser as an HTMLElement.\n * (Shims for older browsers).\n */\nmodule.exports = supportsHTMLType\n ? DOMParserParse\n : fallbackParse\n","'use strict'\n\nsetDOM.KEY = 'data-key'\nsetDOM.IGNORE = 'data-ignore'\nsetDOM.CHECKSUM = 'data-checksum'\nvar parseHTML = require('./parse-html')\nvar KEY_PREFIX = '_set-dom-'\nvar NODE_MOUNTED = KEY_PREFIX + 'mounted'\nvar ELEMENT_TYPE = 1\nvar DOCUMENT_TYPE = 9\nvar DOCUMENT_FRAGMENT_TYPE = 11\n\n// Expose api.\nmodule.exports = setDOM\n\n/**\n * @description\n * Updates existing dom to match a new dom.\n *\n * @param {Node} oldNode - The html entity to update.\n * @param {String|Node} newNode - The updated html(entity).\n */\nfunction setDOM (oldNode, newNode) {\n // Ensure a realish dom node is provided.\n assert(oldNode && oldNode.nodeType, 'You must provide a valid node to update.')\n\n // Alias document element with document.\n if (oldNode.nodeType === DOCUMENT_TYPE) oldNode = oldNode.documentElement\n\n // Document Fragments don't have attributes, so no need to look at checksums, ignored, attributes, or node replacement.\n if (newNode.nodeType === DOCUMENT_FRAGMENT_TYPE) {\n // Simply update all children (and subchildren).\n setChildNodes(oldNode, newNode)\n } else {\n // Otherwise we diff the entire old node.\n setNode(oldNode, typeof newNode === 'string'\n // If a string was provided we will parse it as dom.\n ? parseHTML(newNode, oldNode.nodeName)\n : newNode\n )\n }\n\n // Trigger mount events on initial set.\n if (!oldNode[NODE_MOUNTED]) {\n oldNode[NODE_MOUNTED] = true\n mount(oldNode)\n }\n}\n\n/**\n * @private\n * @description\n * Updates a specific htmlNode and does whatever it takes to convert it to another one.\n *\n * @param {Node} oldNode - The previous HTMLNode.\n * @param {Node} newNode - The updated HTMLNode.\n */\nfunction setNode (oldNode, newNode) {\n if (oldNode.nodeType === newNode.nodeType) {\n // Handle regular element node updates.\n if (oldNode.nodeType === ELEMENT_TYPE) {\n // Checks if nodes are equal before diffing.\n if (isEqualNode(oldNode, newNode)) {\n // console.trace(oldNode)\n return\n }\n\n // Update all children (and subchildren).\n setChildNodes(oldNode, newNode)\n\n // Update the elements attributes / tagName.\n if (oldNode.nodeName === newNode.nodeName) {\n // If we have the same nodename then we can directly update the attributes.\n setAttributes(oldNode.attributes, newNode.attributes)\n } else {\n // Otherwise clone the new node to use as the existing node.\n var newPrev = newNode.cloneNode()\n // Copy over all existing children from the original node.\n while (oldNode.firstChild) newPrev.appendChild(oldNode.firstChild)\n // Replace the original node with the new one with the right tag.\n oldNode.parentNode.replaceChild(newPrev, oldNode)\n }\n } else {\n // Handle other types of node updates (text/comments/etc).\n // If both are the same type of node we can update directly.\n if (oldNode.nodeValue !== newNode.nodeValue) {\n oldNode.nodeValue = newNode.nodeValue\n }\n }\n } else {\n // we have to replace the node.\n oldNode.parentNode.replaceChild(newNode, dismount(oldNode))\n mount(newNode)\n }\n}\n\n/**\n * @private\n * @description\n * Utility that will update one list of attributes to match another.\n *\n * @param {NamedNodeMap} oldAttributes - The previous attributes.\n * @param {NamedNodeMap} newAttributes - The updated attributes.\n */\nfunction setAttributes (oldAttributes, newAttributes) {\n var i, a, b, ns, name\n\n // Remove old attributes.\n for (i = oldAttributes.length; i--;) {\n a = oldAttributes[i]\n ns = a.namespaceURI\n name = a.localName\n b = newAttributes.getNamedItemNS(ns, name)\n if (!b) oldAttributes.removeNamedItemNS(ns, name)\n }\n\n // Set new attributes.\n for (i = newAttributes.length; i--;) {\n a = newAttributes[i]\n ns = a.namespaceURI\n name = a.localName\n b = oldAttributes.getNamedItemNS(ns, name)\n if (!b) {\n // Add a new attribute.\n newAttributes.removeNamedItemNS(ns, name)\n oldAttributes.setNamedItemNS(a)\n } else if (b.value !== a.value) {\n // Update existing attribute.\n b.value = a.value\n }\n }\n}\n\n/**\n * @private\n * @description\n * Utility that will nodes childern to match another nodes children.\n *\n * @param {Node} oldParent - The existing parent node.\n * @param {Node} newParent - The new parent node.\n */\nfunction setChildNodes (oldParent, newParent) {\n var checkOld, oldKey, checkNew, newKey, foundNode, keyedNodes\n var oldNode = oldParent.firstChild\n var newNode = newParent.firstChild\n var extra = 0\n\n // Extract keyed nodes from previous children and keep track of total count.\n while (oldNode) {\n extra++\n checkOld = oldNode\n oldKey = getKey(checkOld)\n oldNode = oldNode.nextSibling\n\n if (oldKey) {\n if (!keyedNodes) keyedNodes = {}\n keyedNodes[oldKey] = checkOld\n }\n }\n\n // Loop over new nodes and perform updates.\n oldNode = oldParent.firstChild\n while (newNode) {\n extra--\n checkNew = newNode\n newNode = newNode.nextSibling\n\n if (keyedNodes && (newKey = getKey(checkNew)) && (foundNode = keyedNodes[newKey])) {\n delete keyedNodes[newKey]\n // If we have a key and it existed before we move the previous node to the new position if needed and diff it.\n if (foundNode !== oldNode) {\n oldParent.insertBefore(foundNode, oldNode)\n } else {\n oldNode = oldNode.nextSibling\n }\n\n setNode(foundNode, checkNew)\n } else if (oldNode) {\n checkOld = oldNode\n oldNode = oldNode.nextSibling\n if (getKey(checkOld)) {\n // If the old child had a key we skip over it until the end.\n oldParent.insertBefore(checkNew, checkOld)\n mount(checkNew)\n } else {\n // Otherwise we diff the two non-keyed nodes.\n setNode(checkOld, checkNew)\n }\n } else {\n // Finally if there was no old node we add the new node.\n oldParent.appendChild(checkNew)\n mount(checkNew)\n }\n }\n\n // Remove old keyed nodes.\n for (oldKey in keyedNodes) {\n extra--\n oldParent.removeChild(dismount(keyedNodes[oldKey]))\n }\n\n // If we have any remaining unkeyed nodes remove them from the end.\n while (--extra >= 0) {\n oldParent.removeChild(dismount(oldParent.lastChild))\n }\n}\n\n/**\n * @private\n * @description\n * Utility to try to pull a key out of an element.\n * Uses 'data-key' if possible and falls back to 'id'.\n *\n * @param {Node} node - The node to get the key for.\n * @return {string|void}\n */\nfunction getKey (node) {\n if (node.nodeType !== ELEMENT_TYPE) return\n var key = node.getAttribute(setDOM.KEY) || node.id\n if (key) return KEY_PREFIX + key\n}\n\n/**\n * Checks if nodes are equal using the following by checking if\n * they are both ignored, have the same checksum, or have the\n * same contents.\n *\n * @param {Node} a - One of the nodes to compare.\n * @param {Node} b - Another node to compare.\n */\nfunction isEqualNode (a, b) {\n // console.log(a, b, isIgnored(a), isIgnored(b))\n return (\n // Check if both nodes are ignored.\n (isIgnored(a) && isIgnored(b)) ||\n // Check if both nodes have the same checksum.\n (getCheckSum(a) === getCheckSum(b)) ||\n // Fall back to native isEqualNode check.\n a.isEqualNode(b)\n )\n}\n\n/**\n * @private\n * @description\n * Utility to try to pull a checksum attribute from an element.\n * Uses 'data-checksum' or user specified checksum property.\n *\n * @param {Node} node - The node to get the checksum for.\n * @return {string|NaN}\n */\nfunction getCheckSum (node) {\n return node.getAttribute(setDOM.CHECKSUM) || NaN\n}\n\n/**\n * @private\n * @description\n * Utility to try to check if an element should be ignored by the algorithm.\n * Uses 'data-ignore' or user specified ignore property.\n *\n * @param {Node} node - The node to check if it should be ignored.\n * @return {boolean}\n */\nfunction isIgnored (node) {\n return node.getAttribute(setDOM.IGNORE) != null\n}\n\n/**\n * Dispatches a mount event for the given node and children.\n *\n * @param {Node} node - the node to mount.\n * @return {node}\n */\nfunction mount (node) {\n return dispatch(node, 'mount')\n}\n\n/**\n * Dispatches a dismount event for the given node and children.\n *\n * @param {Node} node - the node to dismount.\n * @return {node}\n */\nfunction dismount (node) {\n return dispatch(node, 'dismount')\n}\n\n/**\n * Recursively trigger an event for a node and it's children.\n * Only emits events for keyed nodes.\n *\n * @param {Node} node - the initial node.\n * @return {Node}\n */\nfunction dispatch (node, type) {\n // Trigger event for this element if it has a key.\n if (getKey(node)) {\n var ev = document.createEvent('Event')\n var prop = { value: node }\n ev.initEvent(type, false, false)\n Object.defineProperty(ev, 'target', prop)\n Object.defineProperty(ev, 'srcElement', prop)\n node.dispatchEvent(ev)\n }\n\n // Dispatch to all children.\n var child = node.firstChild\n while (child) child = dispatch(child, type).nextSibling\n return node\n}\n\n/**\n * @private\n * @description\n * Confirm that a value is truthy, throws an error message otherwise.\n *\n * @param {*} val - the val to test.\n * @param {string} msg - the error message on failure.\n * @throws {Error}\n */\nfunction assert (val, msg) {\n if (!val) throw new Error('set-dom: ' + msg)\n}\n","import templateParse from './templateParse/index'\r\nimport { setState, addState } from './genElement'\r\nimport { getId, assert } from '../../utils'\r\n\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\n\r\nexport default function (stub) {\r\n templateParse(this, addState)\r\n const el = stub || getId(this.el)\r\n if (el) {\r\n if (el.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n el.setAttribute('data-ignore', '')\r\n } else {\r\n assert(this.base.childNodes.length === 1, 'Sub-component should only has a single rootNode.')\r\n !this.base.firstChild.hasAttribute('data-ignore') && this.base.firstChild.setAttribute('data-ignore', '')\r\n }\r\n // listen to state changes\r\n setState.call(this)\r\n\r\n // mount fragment to DOM\r\n if (!stub) {\r\n el.appendChild(this.base)\r\n }\r\n\r\n // since component already rendered, trigger its life-cycle method\r\n if (this.componentDidMount && typeof this.componentDidMount === 'function') {\r\n this.componentDidMount()\r\n }\r\n } else {\r\n assert(false, 'No element with id: \"' + this.el + '\" exist.')\r\n }\r\n}\r\n","import { clearState } from '../components/genElement'\r\n\r\nconst DOCUMENT_FRAGMENT_TYPE = 11\r\nconst DOCUMENT_TEXT_TYPE = 3\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\n/**\r\n * @private\r\n * @description\r\n * Mount an instance of string or html elements\r\n *\r\n * @param {String|Object} instance - the html/string \r\n */\r\nexport default function(instance) {\r\n let base\r\n let tempDiv\r\n let frag = document.createDocumentFragment()\r\n // Before we begin to parse an instance, do a run-down checks\r\n // to clean up back-tick string which usually has line spacing.\r\n if (typeof instance === 'string') {\r\n base = instance.trim().replace(/\\s+/g, ' ')\r\n tempDiv = document.createElement('div')\r\n tempDiv.innerHTML = base\r\n while (tempDiv.firstChild) {\r\n frag.appendChild(tempDiv.firstChild)\r\n }\r\n // If instance is a html element process as html entities\r\n } else if (typeof instance === 'object' && instance['nodeType']) {\r\n if (instance['nodeType'] === DOCUMENT_ELEMENT_TYPE) {\r\n frag.appendChild(instance)\r\n } else if (instance['nodeType'] === DOCUMENT_FRAGMENT_TYPE) {\r\n frag = instance\r\n } else if (instance['nodeType'] === DOCUMENT_TEXT_TYPE) {\r\n frag.appendChild(instance)\r\n } else {\r\n assert(false, 'Unable to parse instance, unknown type.')\r\n }\r\n } else {\r\n assert(false, 'Parameter is not a string or a html element.')\r\n }\r\n // we store the pristine instance in __pristineFragment__\r\n this.__pristineFragment__ = frag.cloneNode(true)\r\n this.base = frag\r\n\r\n // cleanup states on mount\r\n clearState()\r\n return this\r\n}","export default (str) => {\r\n let res = str.match(/\\.*\\./g)\r\n let result\r\n if (res && res.length > 0) {\r\n return str.split('.')\r\n }\r\n return result\r\n}\r\n","const genId = () => {\r\n const gen = () => (Math.random() * 1 * 1e17).toString(36).toUpperCase()\r\n return 'KDATA-' + gen() + '-' + gen()\r\n}\r\n\r\nconst getId = id => document.getElementById(id)\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Check a node availability in 100ms, if not found silenty skip the event\r\n * or execute a callback\r\n *\r\n * @param {string} id - the node id\r\n * @param {function} callback - the function to execute on success\r\n * @param {function} notFound - the function to execute on failed\r\n */\r\nconst checkNodeAvailability = (component, componentName, callback, notFound) => {\r\n let ele = getId(component.el)\r\n let found = false\r\n let t\r\n function find() {\r\n ele = getId(component.el)\r\n if (ele) {\r\n clearInterval(t)\r\n found = true\r\n callback(component, componentName, ele)\r\n }\r\n }\r\n function fail() {\r\n clearInterval(t)\r\n if (!found && notFound && typeof notFound === 'function') notFound()\r\n }\r\n if (ele) return ele\r\n else {\r\n t = setInterval(find, 0)\r\n // ignore finding the node after sometimes\r\n setTimeout(fail, 100)\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Confirm that a value is truthy, throws an error message otherwise.\r\n *\r\n * @param {*} val - the val to test.\r\n * @param {string} msg - the error message on failure.\r\n * @throws {Error}\r\n */\r\nconst assert = (val, msg) => {\r\n if (!val) throw new Error('(keet) ' + msg)\r\n}\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Simple html template literals MODIFIED from : http://2ality.com/2015/01/template-strings-html.html\r\n * by Dr. Axel Rauschmayer\r\n * no checking for wrapping in root element\r\n * no strict checking\r\n * remove spacing / indentation\r\n * keep all spacing within html tags\r\n * include handling ${} in the literals\r\n */\r\nconst html = (...args) => {\r\n const literals = args.shift()\r\n const substs = args.slice()\r\n\r\n let result = literals.raw.reduce((acc, lit, i) => acc + substs[i - 1] + lit)\r\n // remove spacing, indentation from every line\r\n result = result.split(/\\n+/)\r\n result = result.map(t => t.trim()).join('')\r\n return result\r\n}\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Copy with modification from preact-todomvc. Model constructor with\r\n * registering callback listener in Object.defineProperty. Any modification\r\n * to ```this.list``` instance will subsequently inform all registered listener.\r\n *\r\n * {{model:}}{{/model:}}\r\n *\r\n */\r\nclass createModel {\r\n constructor () {\r\n this.model = []\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Register callback listener of any changes\r\n */\r\n Object.defineProperty(this, 'list', {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return this.model\r\n },\r\n set: function (val) {\r\n this.model = val\r\n this.inform(this.model)\r\n }\r\n })\r\n }\r\n\r\n inform (model) {\r\n this.exec && typeof this.exec === 'function' && this.exec(model)\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Subscribe to the model changes (add/update/destroy)\r\n *\r\n * @param {Object} model - the model including all prototypes\r\n *\r\n */\r\n subscribe (fn) {\r\n this.exec = fn\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Add new object to the model list\r\n *\r\n * @param {Object} obj - new object to add into the model list\r\n *\r\n */\r\n add (obj) {\r\n this.list = this.list.concat(obj)\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Update existing object in the model list\r\n *\r\n * @param {String} lookupId - lookup id property name of the object\r\n * @param {Object} updateObj - the updated properties\r\n *\r\n */\r\n update (lookupId, updateObj) {\r\n this.list = this.list.map(obj =>\r\n obj[lookupId] !== updateObj[lookupId] ? obj : Object.assign(obj, updateObj)\r\n )\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Removed existing object in the model list\r\n *\r\n * @param {String} lookupId - lookup id property name of the object\r\n * @param {String} objId - unique identifier of the lookup id\r\n *\r\n */\r\n destroy (lookupId, objId) {\r\n this.list = this.list.filter(obj =>\r\n obj[lookupId] !== objId\r\n )\r\n }\r\n}\r\n\r\nexport {\r\n createModel,\r\n html,\r\n assert,\r\n checkNodeAvailability,\r\n genId,\r\n getId\r\n}\r\n","import ternaryOps from './ternaryOps'\r\nconst re = new RegExp(/(\\schecked=\")(.*?)(?=\")/g)\r\nlet tmpl = ''\r\n\r\nexport default (string, obj) => {\r\n const arrProps = string.match(/{{([^{}]+)}}/g)\r\n let rep\r\n let isTernary\r\n let i\r\n let len\r\n let match\r\n tmpl = string\r\n for (i = 0, len = arrProps.length; i < len; i++) {\r\n rep = arrProps[i].replace(/{{([^{}]+)}}/g, '$1')\r\n isTernary = ternaryOps.call(obj, rep)\r\n if (isTernary) {\r\n tmpl = tmpl.replace('{{' + rep + '}}', isTernary.value)\r\n } else {\r\n tmpl = tmpl.replace('{{' + rep + '}}', obj[rep])\r\n }\r\n\r\n match = tmpl.match(re)\r\n if (match) {\r\n if (match[0].length === 17) { tmpl = tmpl.replace(' checked=\"checked\"', ' checked') } else { tmpl = tmpl.replace(' checked=\"\"', '') }\r\n }\r\n }\r\n return tmpl\r\n}\r\n","import templateParse from './templateParse/index'\r\nimport strInterpreter from './strInterpreter'\r\nimport morph from 'set-dom'\r\nimport { getId } from '../../utils'\r\n\r\nconst DELAY = 1\r\nlet el\r\n\r\nconst morpher = function () {\r\n el = getId(this.el)\r\n genElement.call(this)\r\n if (el) {\r\n this.IS_STUB ? morph(el, this.base.firstChild) : morph(el, this.base)\r\n }\r\n // exec life-cycle componentDidUpdate\r\n if (this.componentDidUpdate && typeof this.componentDidUpdate === 'function') {\r\n this.componentDidUpdate()\r\n }\r\n}\r\n\r\nlet timer = {}\r\nconst updateContext = function (fn, delay) {\r\n timer[this.ID] = timer[this.ID] || null\r\n clearTimeout(timer[this.ID])\r\n timer[this.ID] = setTimeout(() => fn.call(this), delay)\r\n}\r\n\r\nconst nextState = function (i) {\r\n let state\r\n let value\r\n if (i < stateList.length) {\r\n state = stateList[i]\r\n value = this[state]\r\n\r\n // if value is undefined, likely has object notation we convert it to array\r\n if (value === undefined) value = strInterpreter(state)\r\n\r\n if (value && Array.isArray(value)) {\r\n // using split object notation as base for state update\r\n let inVal = this[value[0]][value[1]]\r\n Object.defineProperty(this[value[0]], value[1], {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return inVal\r\n },\r\n set: function (val) {\r\n inVal = val\r\n updateContext.call(this, morpher, DELAY)\r\n }\r\n })\r\n } else {\r\n // handle parent state update if the state is not an object\r\n Object.defineProperty(this, state, {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return value\r\n },\r\n set: function (val) {\r\n value = val\r\n updateContext.call(this, morpher, DELAY)\r\n }\r\n })\r\n }\r\n i++\r\n nextState.call(this, i)\r\n }\r\n}\r\n\r\nconst setState = function () {\r\n nextState.call(this, 0)\r\n}\r\n\r\nlet stateList = []\r\n\r\nconst clearState = () => {\r\n stateList = []\r\n}\r\n\r\nconst addState = state => {\r\n if (stateList.indexOf(state) === -1) { stateList = stateList.concat(state) }\r\n}\r\n\r\nconst genElement = function () {\r\n this.base = this.__pristineFragment__.cloneNode(true)\r\n templateParse(this, addState)\r\n}\r\n\r\nexport {\r\n genElement,\r\n addState,\r\n setState,\r\n clearState,\r\n updateContext,\r\n morpher\r\n}\r\n","/**\r\n * Keetjs v4.0.0 Alpha release: https://github.com/keetjs/keet.js\r\n * Minimali4.0.0ew layer for the web\r\n *\r\n * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Keetjs >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n *\r\n * Copyright 2018, Shahrul Nizam Selamat\r\n * Released under the MIT License.\r\n */\r\n\r\nimport parseStr from './src/components/parseStr'\r\nimport { updateContext, morpher } from './src/components/genElement'\r\nimport { getId, genId, assert } from './utils'\r\nimport mount from './src/base/mount'\r\n\r\n/**\r\n * @description\r\n * The main constructor of Keet\r\n *\r\n * Basic Usage :-\r\n *\r\n * const App extends Keet {}\r\n * const app = new App()\r\n * app.mount('hello world').link('app')\r\n *\r\n */\r\nclass Keet {\r\n\r\n constructor () {\r\n this.ID = Keet.indentity\r\n }\r\n\r\n // generate ID for the component\r\n static get indentity(){\r\n return genId()\r\n }\r\n\r\n mount (instance) {\r\n return mount.call(this, instance)\r\n }\r\n\r\n link (id) {\r\n // The target DOM where the rendering will took place.\r\n if (!id) assert(id, 'No id is given as parameter.')\r\n this.el = id\r\n this.render()\r\n return this\r\n }\r\n\r\n render (stub) {\r\n // life-cycle method before rendering the component\r\n if (this.componentWillMount && typeof this.componentWillMount === 'function') {\r\n this.componentWillMount()\r\n }\r\n\r\n // Render this component to the target DOM\r\n if (stub) {\r\n this.IS_STUB = true\r\n }\r\n parseStr.call(this, stub)\r\n }\r\n\r\n callBatchPoolUpdate () {\r\n // force component to update, if any state / non-state\r\n // value changed DOM diffing will occur\r\n updateContext.call(this, morpher, 1)\r\n }\r\n\r\n subscribe (fn) {\r\n this.exec = fn\r\n }\r\n\r\n inform (model) {\r\n this.exec && typeof this.exec === 'function' && this.exec(model)\r\n }\r\n\r\n}\r\n\r\nexport default Keet\r\n"]}
\ No newline at end of file
+{"version":3,"sources":["src/components/ternaryOps.js","src/components/templateParse/updateState.js","src/components/templateParse/valAssign.js","src/components/templateParse/replaceHandleBars.js","src/components/conditionalNodes.js","src/components/genModelList.js","src/components/componentParse.js","src/components/templateParse/replaceCommentBlock.js","src/components/templateParse/addEvent.js","src/components/templateParse/index.js","src/components/parseStr.js","src/base/mount.js","src/components/strInterpreter.js","utils.js","src/components/genModelTemplate.js","src/components/genElement.js","keet.js"],"names":["ternaryOps","input","match","t","split","condition","leftHand","rightHand","this","value","test","state","updateState","updateStateList","valAssign","node","replace","withTo","nodeValue","RegExp","replaceHandleBars","ins","templateParse","isAttr","props","re","ln","length","rep","tnr","isObjectNotation","call","strInterpreter","undefined","catchNode","start","cNode","nextSibling","nodeType","DOCUMENT_ELEMENT_TYPE","isEqualNode","remove","firstChild","resolveConditionalNodes","conditional","setup","currentNode","fetchFrag","frag","document","createDocumentFragment","cache","hasOwnProperty","cloneNode","parentNode","insertBefore","conditionalNodesRawEnd","__pristineFragment__","Object","keys","map","c","DOCUMENT_COMMENT_TYPE","appendChild","render","str","obj","m","genModelTemplate","documentFragment","range","createContextualFragment","setAttribute","removeProtoModel","id","after","p","getElementById","childNodes","conditionalCache","cache$$1","genModelList","model","modelList","i","listClone","updateOfNew","diffOfOld","pNode","equalLength","child","list","oldModel","listArg","idx","beforeNode","f","enableFiltering","outerHTML","hasAttribute","diff","diffModel","_len","arguments","args","Array","_key","pop","querySelector","replaceChild","lastChild","indexOf","removeChild","JSON","parse","stringify","getId","checkNodeAvailability","el","bind","componentParse","componentStr","component","cacheInit","ID","callBatchPoolUpdate","base","assert","replaceCommentBlock","conditionalRep","modelRep","trim","conditionalRe","conditionalNodes","lookupParentNode","rootNode","getAttribute","addEvent","evtData","isModel","evtName","handler","addEventListener","fn","e","stopPropagation","target","currentTarget","getIndex","addEventModel","ctx","modelInstance","modelObject","type","isEqual","oldNode","newNode","isIgnored","arbiter","nodeName","checked","setAttr","oAttr","attributes","output","name","iAttr","j","attr","removeAttribute","patch","store","count","newStore","checkNew","push","index","oldParentNode","checkOld","fragment","instance","inspectAttributes","nodeAttributes","a","ns","localName","testEventNode","evtStore","obs","hasChildNodes","modelRaw","rd","minId","cacheEvents","events","addEvt","hasAttributes","check","IS_STUB","parseStr","stub","addState","setState","componentDidMount","_mount","tempDiv","createElement","innerHTML","_typeof","DOCUMENT_FRAGMENT_TYPE","DOCUMENT_TEXT_TYPE","clearState","res","result","genId","Math","random","toString","componentName","callback","notFound","find","ele","clearInterval","found","fail","setInterval","setTimeout","val","msg","Error","notEqual","b","inform","_len2","_key2","exec","apply","createModel","defineProperty","enumerable","configurable","get","set","listFilter","_this","prop","filter","subscribe","add","concat","_extends","kdata-id","update","updateObj","destroy","destroyObj","tmpl","isTernary","len","string","arrProps","fst","sec","some","inr","predicate","createRange","DELAY","morpher","genElement","componentDidUpdate","timer","updateContext","delay","clearTimeout","nextState","self","stateList","isArray","inVal","Keet","indentity","mount","link","componentWillMount"],"mappings":"gCAIe,SAAAA,GAAUC,GACvB,GAAIA,EAAMC,MAAM,4CAA6C,CAC3D,GAAIC,GAAIF,EAAMG,MAAM,KAChBC,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O/O,KAGhEmQ,GAAa,WACjBtQ,KAAKsH,KAAOtH,KAAKiD,qBAAqBJ,WAAU,GAChD/B,EAAcd,KAAMiM,GAAU,KAAM,KAAM,KAAM,WAChDnL,EAAcd,KAAMiM,GAAU,KAAM,KAAM,KAAM,UAChDnL,EAAcd,KAAM,KAAM,KAAM,KAAM,KAAM,SAC5Cc,EAAcd,KAAM,KAAM,KAAM,KAAM,KAAM,SLjFxC+B,GAAwB,ECDxB0K,GAAyB,GACzBC,GAAqB,EACrB3K,GAAwB,QKyBxBkP,YACJ,QAAAA,KACEjR,KAAKoH,GAAK6J,EAAKC,6BAQjBC,MAAAA,SAAOvG,GACL,MAAOuG,GAAM5P,KAAKvB,KAAM4K,gBAG1BwG,KAAAA,SAAMlN,GAKJ,MAHKA,IAAIqD,EAAOrD,EAAI,gCACpBlE,KAAK8G,GAAK5C,EACVlE,KAAKwD,SACExD,kBAGTwD,OAAAA,SAAQwI,GAEFhM,KAAKqR,oBAAyD,kBAA5BrR,MAAKqR,oBACzCrR,KAAKqR,qBAIHrF,IACFhM,KAAK8L,SAAU,GAEjBC,EAASxK,KAAKvB,KAAMgM,gBAGtB3E,oBAAAA,WAGEoJ,GAAclP,KAAKvB,KAAMqQ,GAAS,gBAGpCrB,UAAAA,SAAWzG,GACTvI,KAAKoO,KAAO7F,eAGd0F,OAAAA,SAAQvJ,GACN1E,KAAKoO,MAA6B,kBAAdpO,MAAKoO,MAAuBpO,KAAKoO,KAAK1J,8CAvC1D,MAAOoI","file":"keet-min.js","sourcesContent":["// function to resolve ternary operation\r\n\r\nconst test = str => str === '\\'\\'' || str === '\"\"' || str === 'null' ? '' : str\r\n\r\nexport default function (input) {\r\n if (input.match(/([^?]*)\\?([^:]*):([^;]*)|(\\s*=\\s*)[^;]*/g)) {\r\n let t = input.split('?')\r\n let condition = t[0]\r\n let leftHand = t[1].split(':')[0]\r\n let rightHand = t[1].split(':')[1]\r\n\r\n // check the condition fulfillment\r\n\r\n if (this) {\r\n if (this[condition]) {\r\n return {\r\n value: test(leftHand),\r\n state: condition\r\n }\r\n } else {\r\n return {\r\n value: test(rightHand),\r\n state: condition\r\n }\r\n }\r\n }\r\n return false\r\n } else return false\r\n}\r\n","export default function (state, updateStateList) {\r\n if (typeof updateStateList === 'function') updateStateList(state)\r\n}\r\n","export default function (node, value, replace, withTo) {\r\n let re = new RegExp(replace, 'g')\r\n node.nodeValue = node.nodeValue.replace(re, withTo)\r\n}\r\n","import ternaryOps from '../ternaryOps'\r\nimport strInterpreter from '../strInterpreter'\r\nimport updateState from './updateState'\r\nimport valAssign from './valAssign'\r\n\r\nconst re = /{{([^{}]+)}}/g\r\n\r\nexport default function (value, node, ins, updateStateList, templateParse, isAttr) {\r\n const props = value.match(re)\r\n let ln = props.length\r\n let rep\r\n let tnr\r\n let isObjectNotation\r\n\r\n while (ln) {\r\n ln--\r\n rep = props[ln].replace(re, '$1')\r\n tnr = ternaryOps.call(ins, rep)\r\n isObjectNotation = strInterpreter(rep)\r\n if (isObjectNotation) {\r\n updateState(rep, updateStateList)\r\n if (!isAttr) {\r\n valAssign(node, value, '{{' + rep + '}}', ins[isObjectNotation[0]][isObjectNotation[1]])\r\n } else {\r\n return value.replace(props, ins[isObjectNotation[0]][isObjectNotation[1]])\r\n }\r\n } else {\r\n if (tnr) {\r\n updateState(tnr.state, updateStateList)\r\n if (!isAttr) {\r\n valAssign(node, value, '{{' + rep + '}}', tnr.value)\r\n } else {\r\n return value.replace(props, tnr.value)\r\n }\r\n } else {\r\n if (ins[rep] !== undefined) {\r\n updateState(rep, updateStateList)\r\n if (!isAttr) {\r\n valAssign(node, value, '{{' + rep + '}}', ins[rep])\r\n } else {\r\n return value.replace(props, ins[rep])\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","const conditionalNodesRawEnd = /\\{\\{\\/([^{}]+)\\}\\}/g\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\nconst DOCUMENT_COMMENT_TYPE = 8\r\n\r\nlet cache = {}\r\n\r\n// rebuild the node structure\r\nfunction catchNode (node, start) {\r\n let cNode\r\n while (node) {\r\n cNode = node\r\n node = node.nextSibling\r\n if (cNode && cNode.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n if (cNode.isEqualNode(start)) {\r\n cNode.remove()\r\n start = start.nextSibling\r\n } else {\r\n catchNode(cNode.firstChild, start)\r\n }\r\n } else if (cNode.isEqualNode(start)) {\r\n cNode.remove()\r\n start = start.nextSibling\r\n }\r\n }\r\n}\r\n\r\nfunction resolveConditionalNodes (node, updateStateList, conditional, templateParse, setup) {\r\n let currentNode\r\n let cNode\r\n let fetchFrag\r\n let frag = document.createDocumentFragment()\r\n\r\n if (setup === 'initial' && !cache.hasOwnProperty(conditional)) {\r\n cNode = node\r\n while (cNode) {\r\n currentNode = cNode\r\n cNode = cNode.nextSibling\r\n if (currentNode.nodeType !== DOCUMENT_ELEMENT_TYPE && currentNode.nodeValue.match(conditionalNodesRawEnd)) {\r\n cNode = null\r\n cache[conditional] = cache[conditional] || {}\r\n\r\n // clean up pristine node\r\n catchNode(this.__pristineFragment__.firstChild, frag.firstChild)\r\n // also clean up cache for recursive handlers\r\n Object.keys(cache).map(c =>\r\n c !== conditional && catchNode(cache[c].frag.firstChild, frag.firstChild)\r\n )\r\n\r\n cache[conditional].frag = frag\r\n fetchFrag = cache[conditional].frag.cloneNode(true)\r\n // resolve recursive conditional handlers as well\r\n templateParse(this, null, null, null, fetchFrag, 'initial')\r\n // update current if conditional is truthy\r\n if (this[conditional]) {\r\n currentNode.parentNode.insertBefore(fetchFrag, currentNode)\r\n }\r\n } else if (currentNode.nodeType !== DOCUMENT_COMMENT_TYPE) {\r\n frag.appendChild(currentNode)\r\n }\r\n }\r\n } else {\r\n if (node.nextSibling.isEqualNode(cache[conditional].frag.firstChild)) return\r\n fetchFrag = cache[conditional].frag.cloneNode(true)\r\n if (this[conditional]) {\r\n node.parentNode.insertBefore(fetchFrag, node.nextSibling)\r\n } else {\r\n // templateParse(this, null, null, null, fetchFrag, 'update')\r\n }\r\n }\r\n}\r\n\r\nexport {\r\n resolveConditionalNodes as default,\r\n cache\r\n}\r\n","import { getId, checkNodeAvailability } from '../../utils'\r\nimport genModelTemplate from './genModelTemplate'\r\nimport { cache as conditionalCache } from './conditionalNodes'\r\n\r\n// diffing two array of objects, including object properties differences\r\nconst diff = (fst, sec) =>\r\n fst.filter(obj =>\r\n !sec.some(inr => {\r\n let predicate = true\r\n for (let attr in inr) {\r\n if (obj[attr] !== inr[attr]) {\r\n predicate = false\r\n }\r\n }\r\n return predicate\r\n })\r\n )\r\n\r\n// check if browser support createRange\r\nlet range\r\n\r\nif (typeof document.createRange === 'function') {\r\n range = document.createRange()\r\n}\r\n\r\n// storage for model state\r\nlet cache = {}\r\nlet m\r\nlet documentFragment\r\n\r\nfunction render (str, obj) {\r\n m = genModelTemplate(str, obj)\r\n documentFragment = range.createContextualFragment(m)\r\n documentFragment.firstChild.setAttribute('kdata-id', obj['kdata-id'])\r\n}\r\n\r\nfunction removeProtoModel (node, id, after) {\r\n let p = node.getElementById(id)\r\n if (p) p.childNodes[1].remove()\r\n else if (!after) {\r\n Object.keys(conditionalCache).map(cache =>\r\n removeProtoModel(conditionalCache[cache].frag, id, true)\r\n )\r\n }\r\n}\r\n\r\nfunction genModelList (node, model, templateParse) {\r\n let modelList\r\n let i\r\n let listClone\r\n let parentNode\r\n let updateOfNew\r\n let diffOfOld\r\n let pNode\r\n let equalLength\r\n let child\r\n let list\r\n let str\r\n let oldModel\r\n let listArg\r\n let idx\r\n let beforeNode\r\n let f\r\n\r\n cache[model] = cache[model] || {}\r\n\r\n // check if the model use filtering\r\n listArg = this[model] && this[model].enableFiltering ? 'listFilter' : 'list'\r\n\r\n if (!cache[model][listArg]) {\r\n cache[model][listArg] = node.nextSibling.cloneNode(true)\r\n }\r\n list = cache[model][listArg]\r\n\r\n if (!cache[model].str) {\r\n cache[model].str = node.nextSibling.cloneNode(true).outerHTML\r\n // remove the first prototype node\r\n node.nextSibling.remove()\r\n // also remove from pristine nodes / conditional cache store\r\n removeProtoModel(this.__pristineFragment__, node.parentNode.id)\r\n }\r\n str = cache[model].str\r\n\r\n if (this[model] !== undefined && this[model].hasOwnProperty(listArg)) {\r\n parentNode = node.parentNode\r\n\r\n if (range && !parentNode.hasAttribute('data-ignore')) {\r\n parentNode.setAttribute('data-ignore', '')\r\n }\r\n\r\n modelList = this[model][listArg]\r\n\r\n oldModel = cache[model].oldModel || []\r\n\r\n // check if current browser doesn't support createRange()\r\n if (!range) {\r\n i = 0\r\n while (i < modelList.length) {\r\n // fallback to regular node generation handler\r\n listClone = list.cloneNode(true)\r\n templateParse(this, null, listClone, modelList[i], null, 'update')\r\n listClone.setAttribute('kdata-id', modelList[i]['kdata-id'])\r\n parentNode.insertBefore(listClone, parentNode.lastChild)\r\n i++\r\n }\r\n } else {\r\n updateOfNew = diff(modelList, oldModel)\r\n diffOfOld = diff(oldModel, modelList)\r\n\r\n const diffModel = function (...args) {\r\n pNode = args.pop()\r\n // check if both models are equally in length\r\n equalLength = oldModel.length === modelList.length\r\n\r\n if (equalLength && pNode.childNodes.length !== 2) {\r\n i = 0\r\n while (i < updateOfNew.length) {\r\n if (updateOfNew[i]['kdata-id'] === diffOfOld[i]['kdata-id']) {\r\n // equal node element id\r\n child = pNode.querySelector(`[kdata-id=\"${updateOfNew[i]['kdata-id']}\"]`)\r\n } else {\r\n // replace if it doesn't share the same id\r\n child = pNode.querySelector(`[kdata-id=\"${diffOfOld[i]['kdata-id']}\"]`)\r\n }\r\n if (child) {\r\n render(str, updateOfNew[i])\r\n pNode.replaceChild(documentFragment, child)\r\n }\r\n i++\r\n }\r\n // add new objects\r\n } else if (updateOfNew.length > 0 && diffOfOld.length === 0) {\r\n i = 0\r\n while (i < updateOfNew.length) {\r\n render(str, updateOfNew[i])\r\n if (updateOfNew[i]['kdata-id'] === modelList[modelList.length - 1]['kdata-id']) {\r\n beforeNode = pNode.lastChild\r\n } else {\r\n idx = modelList.map(m => m['kdata-id']).indexOf(updateOfNew[i]['kdata-id'])\r\n beforeNode = pNode.childNodes[idx].nextSibling\r\n }\r\n pNode.insertBefore(documentFragment, beforeNode)\r\n i++\r\n }\r\n // destroy selected objects\r\n } else if (updateOfNew.length === 0 && diffOfOld.length > 0) {\r\n i = 0\r\n while (i < diffOfOld.length) {\r\n child = pNode.querySelector(`[kdata-id=\"${diffOfOld[i]['kdata-id']}\"]`)\r\n if (child) {\r\n pNode.removeChild(child)\r\n }\r\n i++\r\n }\r\n } else if (updateOfNew.length > 0 && diffOfOld.length > 0) {\r\n // if both differences has length we remove the old children and replace it with the new ones\r\n i = 0\r\n while (i < diffOfOld.length) {\r\n child = pNode.querySelector(`[kdata-id=\"${diffOfOld[i]['kdata-id']}\"]`)\r\n if (child) {\r\n pNode.removeChild(child)\r\n }\r\n i++\r\n if (i === diffOfOld.length) {\r\n f = 0\r\n while (f < updateOfNew.length) {\r\n render(str, updateOfNew[f])\r\n pNode.insertBefore(documentFragment, pNode.lastChild)\r\n f++\r\n }\r\n }\r\n }\r\n } else {\r\n i = 0\r\n while (i < modelList.length) {\r\n render(str, modelList[i])\r\n pNode.insertBefore(documentFragment, pNode.lastChild)\r\n i++\r\n }\r\n }\r\n // replace oldModel after diffing\r\n cache[model].oldModel = JSON.parse(JSON.stringify(modelList))\r\n }\r\n\r\n // check existing parentNode in the DOM\r\n if (parentNode.hasAttribute('id')) {\r\n pNode = getId(parentNode.id)\r\n if (pNode) {\r\n diffModel.call(this, null, null, pNode)\r\n } else {\r\n checkNodeAvailability({ el: parentNode.id }, model, diffModel.bind(this), function () {\r\n // we cleanup cache on failed search\r\n cache[model].oldModel = []\r\n })\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport default genModelList\r\n","import { assert, getId } from '../../utils'\r\n\r\nlet cacheInit = {}\r\n\r\nexport default function (componentStr, node) {\r\n const component = componentStr.replace('component:', '')\r\n const c = this[component]\r\n\r\n if (c !== undefined) {\r\n // this is for initial component runner\r\n if (!cacheInit[c.ID]) {\r\n c.render(true)\r\n cacheInit[c.ID] = c.base.cloneNode(true)\r\n node.parentNode.replaceChild(c.base, node)\r\n } else {\r\n // we need to reattach event listeners if the node is not available on DOM\r\n if (!getId(this[component].el)) {\r\n c.base = c.__pristineFragment__.cloneNode(true)\r\n c.render(true)\r\n node.parentNode.replaceChild(c.base, node)\r\n } else {\r\n node.parentNode.replaceChild(cacheInit[c.ID].cloneNode(true), node)\r\n // inform sub-component to update\r\n c.callBatchPoolUpdate()\r\n }\r\n }\r\n } else {\r\n assert(false, 'Component ' + component + ' does not exist.')\r\n }\r\n}\r\n","import genModelList from '../genModelList'\r\nimport conditionalNodes from '../conditionalNodes'\r\nimport updateState from './updateState'\r\nimport componentParse from '../componentParse'\r\n\r\nconst re = /{{([^{}]+)}}/g\r\nconst model = /^model:/g\r\nconst conditionalRe = /^\\?/g\r\nconst component = /^component:([^{}]+)/g\r\n\r\nexport default function (value, node, ins, updateStateList, templateParse, setup) {\r\n let conditionalRep\r\n let rep\r\n let modelRep\r\n\r\n if (value.match(re)) {\r\n rep = value.replace(re, '$1').trim()\r\n if (rep.match(model) && setup !== 'initial') {\r\n modelRep = rep.replace('model:', '')\r\n genModelList.call(this, node, modelRep, templateParse)\r\n } else if (rep.match(conditionalRe)) {\r\n conditionalRep = rep.replace('?', '')\r\n if (ins[conditionalRep] !== undefined) {\r\n updateState(conditionalRep, updateStateList)\r\n conditionalNodes.call(this, node, updateStateList, conditionalRep, templateParse, setup)\r\n }\r\n } else if (rep.match(component) && setup !== 'initial') {\r\n componentParse.call(this, rep, node)\r\n }\r\n }\r\n}\r\n","const DOCUMENT_ELEMENT_TYPE = 1\r\nconst re = /{{([^{}]+)}}/g\r\n\r\nfunction lookupParentNode (rootNode, node) {\r\n let cNode\r\n while (node) {\r\n cNode = node\r\n node = node.parentNode\r\n if (cNode.nodeType === DOCUMENT_ELEMENT_TYPE && cNode.hasAttribute('kdata-id')) {\r\n return { id: cNode.getAttribute('kdata-id'), node: cNode }\r\n }\r\n if (cNode.isEqualNode(rootNode)) {\r\n node = null\r\n }\r\n }\r\n}\r\n\r\nconst getIndex = (id, model) => model.list.map(m => m['kdata-id']).indexOf(id)\r\n\r\nfunction addEvent (node, evtData) {\r\n delete evtData.isModel\r\n let evtName = Object.keys(evtData)[0]\r\n let handler = evtData[evtName]\r\n if (this[handler] !== undefined && typeof this[handler] === 'function') {\r\n node.addEventListener(evtName, this[handler].bind(this), !!evtData['useCapture'])\r\n }\r\n}\r\n\r\nfunction fn (model, handler, node, e) {\r\n e.stopPropagation()\r\n if (e.target !== e.currentTarget) {\r\n let t = lookupParentNode(node, e.target)\r\n this[handler](model.list[getIndex(t.id, model)], e.target, t.node, e)\r\n }\r\n}\r\n\r\nfunction addEventModel (node, evtData) {\r\n delete evtData.isModel\r\n let evtName = Object.keys(evtData)[0]\r\n let handler = evtData[evtName]\r\n if (this[handler] !== undefined && typeof this[handler] === 'function') {\r\n let rep = node.firstChild.nodeValue.replace(re, '$1').trim()\r\n rep = rep.replace('model:', '')\r\n let model = this[rep]\r\n node.addEventListener(evtName, fn.bind(this, model, handler, node), !!evtData['useCapture'])\r\n }\r\n}\r\n\r\nexport {\r\n addEvent,\r\n addEventModel\r\n}\r\n","import replaceHandleBars from './replaceHandleBars'\r\nimport replaceCommentBlock from './replaceCommentBlock'\r\nimport { addEvent, addEventModel } from './addEvent'\r\nimport { getId, minId } from '../../../utils'\r\n\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\nconst DOCUMENT_COMMENT_TYPE = 8\r\nconst re = /{{([^{}]+)}}/g\r\nconst modelRaw = /\\{\\{model:([^{}]+)\\}\\}/g\r\n\r\nlet cacheEvents = []\r\n\r\nfunction templateParse (ctx, updateStateList, modelInstance, modelObject, conditional, type) {\r\n let currentNode\r\n let fragment\r\n let instance\r\n\r\n if (modelObject) {\r\n instance = modelInstance\r\n } else if (conditional) {\r\n instance = conditional.firstChild\r\n } else {\r\n fragment = ctx.base\r\n instance = fragment.firstChild\r\n }\r\n\r\n let ins = modelObject || ctx\r\n\r\n const inspectAttributes = node => {\r\n let nodeAttributes = node.attributes\r\n let i = 0\r\n let a\r\n let ns\r\n let name\r\n\r\n for (i = nodeAttributes.length; i--;) {\r\n a = nodeAttributes[i]\r\n name = a.localName\r\n ns = a.nodeValue\r\n if (re.test(name)) {\r\n node.removeAttribute(name)\r\n name = replaceHandleBars(name, node, ins, null, null, true)\r\n node.setAttribute(name, ns)\r\n } else if (re.test(ns)) {\r\n ns = replaceHandleBars(ns, node, ins, null, null, true)\r\n if (name === 'checked') {\r\n if (ns === '') {\r\n node.checked = false\r\n } else {\r\n node.checked = true\r\n }\r\n node.removeAttribute(name)\r\n } else {\r\n if (ns === '') {\r\n node.setAttribute(name, '')\r\n } else {\r\n node.setAttribute(name, ns)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n const testEventNode = node => {\r\n let nodeAttributes = node.attributes\r\n let i = 0\r\n let a\r\n let name\r\n let value\r\n let evtName\r\n let handler\r\n let evtStore = []\r\n let obs\r\n let args\r\n\r\n while (i < nodeAttributes.length) {\r\n a = nodeAttributes[i]\r\n name = a.localName\r\n value = a.nodeValue\r\n if (/^k-/.test(name)) {\r\n evtName = name.replace(/^k-/, '')\r\n handler = value.match(/[a-zA-Z]+(?![^(]*\\))/)[0]\r\n args = value.match(/\\(([^{}]+)\\)/)\r\n args = args ? args[1] : ''\r\n obs = {}\r\n obs[evtName] = handler\r\n if (args) obs[args] = true\r\n obs['isModel'] = false\r\n evtStore.push(obs)\r\n if (node.hasChildNodes() && node.firstChild.nodeType !== DOCUMENT_ELEMENT_TYPE && node.firstChild.nodeValue.match(modelRaw)) {\r\n obs['isModel'] = true\r\n }\r\n }\r\n i++\r\n }\r\n if (evtStore.length && !node.hasAttribute('evt-data')) {\r\n let rd = minId()\r\n node.setAttribute('evt-data', rd)\r\n cacheEvents[rd] = evtStore\r\n }\r\n return evtStore\r\n }\r\n\r\n let events\r\n\r\n const addEvt = (node, type) => {\r\n while (node) {\r\n currentNode = node\r\n node = node.nextSibling\r\n if (currentNode.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n if (currentNode.hasAttributes() && !getId(currentNode.id)) {\r\n events = testEventNode.call(ctx, currentNode)\r\n if (events.length) {\r\n events.map(e =>\r\n !e.isModel ? addEvent.call(ctx, currentNode, e) : addEventModel.call(ctx, currentNode, e)\r\n )\r\n }\r\n }\r\n addEvt(currentNode.firstChild, type)\r\n }\r\n }\r\n }\r\n\r\n const check = (node, type) => {\r\n while (node) {\r\n currentNode = node\r\n node = node.nextSibling\r\n if (currentNode.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n if (type === 'update' && currentNode.hasAttributes()) {\r\n inspectAttributes(currentNode)\r\n }\r\n check(currentNode.firstChild, type)\r\n } else if (currentNode.nodeValue.match(re)) {\r\n if (currentNode.nodeType === DOCUMENT_COMMENT_TYPE) {\r\n replaceCommentBlock.call(ctx, currentNode.nodeValue, currentNode, ins, updateStateList, templateParse, type)\r\n } else if (type === 'update') {\r\n replaceHandleBars.call(ctx, currentNode.nodeValue, currentNode, ins, updateStateList, templateParse)\r\n }\r\n }\r\n }\r\n }\r\n\r\n function isEqual (oldNode, newNode) {\r\n return (\r\n (isIgnored(oldNode) && isIgnored(newNode)) ||\r\n oldNode.isEqualNode(newNode)\r\n )\r\n }\r\n\r\n function isIgnored (node) {\r\n return node.getAttribute('data-ignore') != null\r\n }\r\n\r\n function arbiter (oldNode, newNode) {\r\n if (oldNode.nodeName !== 'INPUT') return\r\n if (oldNode.checked !== newNode.checked) {\r\n oldNode.checked = newNode.checked\r\n }\r\n }\r\n\r\n function setAttr (oldNode, newNode) {\r\n let oAttr = newNode.attributes\r\n let output = {}\r\n let i = 0\r\n while (i < oAttr.length) {\r\n output[oAttr[i].name] = oAttr[i].value\r\n i++\r\n }\r\n let iAttr = oldNode.attributes\r\n let input = {}\r\n let j = 0\r\n while (j < iAttr.length) {\r\n input[iAttr[j].name] = iAttr[j].value\r\n j++\r\n }\r\n for (let attr in output) {\r\n if (oldNode.attributes[attr] && oldNode.attributes[attr].name === attr && oldNode.attributes[attr].value !== output[attr]) {\r\n oldNode.setAttribute(attr, output[attr])\r\n } else {\r\n if (!oldNode.hasAttribute(attr)) {\r\n oldNode.setAttribute(attr, output[attr])\r\n }\r\n }\r\n }\r\n for (let attr in input) {\r\n if (newNode.attributes[attr] && oldNode.attributes[attr]) {\r\n } else if (attr !== 'evt-data') {\r\n oldNode.removeAttribute(attr)\r\n }\r\n }\r\n }\r\n\r\n function patch (oldNode, newNode) {\r\n if (oldNode.nodeType === newNode.nodeType) {\r\n if (oldNode.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n arbiter(oldNode, newNode)\r\n if (isEqual(oldNode, newNode)) return\r\n diff(oldNode.firstChild, newNode.firstChild)\r\n if (oldNode.nodeName === newNode.nodeName) {\r\n setAttr(oldNode, newNode)\r\n } else {\r\n oldNode.parentNode.replaceChild(newNode, oldNode)\r\n }\r\n } else {\r\n if (oldNode.nodeValue !== newNode.nodeValue) {\r\n oldNode.nodeValue = newNode.nodeValue\r\n }\r\n }\r\n } else {\r\n oldNode.parentNode.replaceChild(newNode, oldNode)\r\n }\r\n }\r\n\r\n function getIndex (store, count) {\r\n return store.length - count - 1\r\n }\r\n\r\n let checkNew\r\n let checkOld\r\n\r\n function diff (oldNode, newNode) {\r\n let count = 0\r\n let newStore = []\r\n while (newNode) {\r\n count++\r\n checkNew = newNode\r\n newNode = newNode.nextSibling\r\n newStore.push(checkNew)\r\n }\r\n let index\r\n let oldParentNode = oldNode && oldNode.parentNode\r\n while (oldNode) {\r\n count--\r\n checkOld = oldNode\r\n oldNode = oldNode.nextSibling\r\n index = getIndex(newStore, count)\r\n if (checkOld && newStore[index]) {\r\n patch(checkOld, newStore[index])\r\n } else if (checkOld && !newStore[index]) {\r\n oldParentNode.removeChild(checkOld)\r\n }\r\n if (oldNode === null) {\r\n while (count > 0) {\r\n count--\r\n index = getIndex(newStore, count)\r\n oldParentNode.appendChild(newStore[index])\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (type === 'initial' || type === 'update') {\r\n check(instance, type)\r\n } else if (type === 'event') {\r\n addEvt(instance, type)\r\n } else if (type === 'diff') {\r\n let base = getId(ctx.el)\r\n if (base && !ctx.IS_STUB) {\r\n diff(base.firstChild, instance)\r\n } else if (base) {\r\n diff(base, instance)\r\n }\r\n }\r\n}\r\n\r\nexport default templateParse\r\n","import templateParse from './templateParse/index'\r\nimport { setState, addState } from './genElement'\r\nimport { getId, assert } from '../../utils'\r\n\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\n\r\nexport default function (stub) {\r\n templateParse(this, addState, null, null, null, 'initial')\r\n templateParse(this, addState, null, null, null, 'update')\r\n templateParse(this, addState, null, null, null, 'event')\r\n const el = stub || getId(this.el)\r\n if (el) {\r\n if (el.nodeType === DOCUMENT_ELEMENT_TYPE) {\r\n el.setAttribute('data-ignore', '')\r\n } else {\r\n assert(this.base.childNodes.length === 1, 'Sub-component should only has a single rootNode.')\r\n !this.base.firstChild.hasAttribute('data-ignore') && this.base.firstChild.setAttribute('data-ignore', '')\r\n }\r\n // listen to state changes\r\n setState.call(this)\r\n // mount fragment to DOM\r\n if (!stub) {\r\n el.appendChild(this.base)\r\n }\r\n\r\n // since component already rendered, trigger its life-cycle method\r\n if (this.componentDidMount && typeof this.componentDidMount === 'function') {\r\n this.componentDidMount()\r\n }\r\n } else {\r\n assert(false, 'No element with id: \"' + this.el + '\" exist.')\r\n }\r\n}\r\n","import { clearState } from '../components/genElement'\r\nimport { assert } from '../../utils'\r\n\r\nconst DOCUMENT_FRAGMENT_TYPE = 11\r\nconst DOCUMENT_TEXT_TYPE = 3\r\nconst DOCUMENT_ELEMENT_TYPE = 1\r\n/**\r\n * @private\r\n * @description\r\n * Mount an instance of string or html elements\r\n *\r\n * @param {String|Object} instance - the html/string\r\n */\r\nexport default function (instance) {\r\n let base\r\n let tempDiv\r\n let frag = document.createDocumentFragment()\r\n // Before we begin to parse an instance, do a run-down checks\r\n // to clean up back-tick string which usually has line spacing.\r\n if (typeof instance === 'string') {\r\n base = instance.trim().replace(/\\s+/g, ' ')\r\n tempDiv = document.createElement('div')\r\n tempDiv.innerHTML = base\r\n while (tempDiv.firstChild) {\r\n frag.appendChild(tempDiv.firstChild)\r\n }\r\n // If instance is a html element process as html entities\r\n } else if (typeof instance === 'object' && instance['nodeType']) {\r\n if (instance['nodeType'] === DOCUMENT_ELEMENT_TYPE) {\r\n frag.appendChild(instance)\r\n } else if (instance['nodeType'] === DOCUMENT_FRAGMENT_TYPE) {\r\n frag = instance\r\n } else if (instance['nodeType'] === DOCUMENT_TEXT_TYPE) {\r\n frag.appendChild(instance)\r\n } else {\r\n assert(false, 'Unable to parse instance, unknown type.')\r\n }\r\n } else {\r\n assert(false, 'Parameter is not a string or a html element.')\r\n }\r\n // we store the pristine instance in __pristineFragment__\r\n this.__pristineFragment__ = frag.cloneNode(true)\r\n this.base = frag\r\n\r\n // cleanup states on mount\r\n clearState()\r\n return this\r\n}\r\n","export default (str) => {\r\n let res = str.match(/\\.*\\./g)\r\n let result\r\n if (res && res.length > 0) {\r\n return str.split('.')\r\n }\r\n return result\r\n}\r\n","const genId = () => {\r\n const rd = () => (Math.random() * 1 * 1e17).toString(36)\r\n return `KDATA-${rd()}-${rd()}`\r\n}\r\n\r\nconst minId = () => (Math.random() * 1 * 1e17).toString(36)\r\n\r\nconst getId = id => document.getElementById(id)\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Check a node availability in 100ms, if not found silenty skip the event\r\n * or execute a callback\r\n *\r\n * @param {string} id - the node id\r\n * @param {function} callback - the function to execute on success\r\n * @param {function} notFound - the function to execute on failed\r\n */\r\nconst checkNodeAvailability = (component, componentName, callback, notFound) => {\r\n let ele = getId(component.el)\r\n let found = false\r\n let t\r\n function find () {\r\n ele = getId(component.el)\r\n if (ele) {\r\n clearInterval(t)\r\n found = true\r\n callback(component, componentName, ele)\r\n }\r\n }\r\n function fail () {\r\n clearInterval(t)\r\n if (!found && notFound && typeof notFound === 'function') notFound()\r\n }\r\n if (ele) return ele\r\n else {\r\n t = setInterval(find, 0)\r\n // ignore finding the node after sometimes\r\n setTimeout(fail, 5)\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Confirm that a value is truthy, throws an error message otherwise.\r\n *\r\n * @param {*} val - the val to test.\r\n * @param {string} msg - the error message on failure.\r\n * @throws {Error}\r\n */\r\nconst assert = (val, msg) => {\r\n if (!val) throw new Error('(keet) ' + msg)\r\n}\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Simple html template literals MODIFIED from : http://2ality.com/2015/01/template-strings-html.html\r\n * by Dr. Axel Rauschmayer\r\n * no checking for wrapping in root element\r\n * no strict checking\r\n * remove spacing / indentation\r\n * keep all spacing within html tags\r\n * include handling ${} in the literals\r\n */\r\nconst html = (...args) => {\r\n const literals = args.shift()\r\n const substs = args.slice()\r\n\r\n let result = literals.raw.reduce((acc, lit, i) => acc + substs[i - 1] + lit)\r\n // remove spacing, indentation from every line\r\n result = result.split(/\\n+/)\r\n result = result.map(t => t.trim()).join('')\r\n return result\r\n}\r\n\r\nconst notEqual = function (a, b) {\r\n return a['kdata-id'] !== b['kdata-id']\r\n}\r\n\r\nconst inform = function (...args) {\r\n this.exec && typeof this.exec === 'function' && this.exec.apply(null, args)\r\n}\r\n\r\n/**\r\n * @private\r\n * @description\r\n * Copy with modification from preact-todomvc. Model constructor with\r\n * registering callback listener in Object.defineProperty. Any modification\r\n * to ```this.list``` instance will subsequently inform all registered listener.\r\n *\r\n * {{model:}}{{/model:}}\r\n *\r\n */\r\nclass createModel {\r\n constructor (enableFiltering) {\r\n // if enableFiltering is assigned a value, model generation will\r\n // use `listFilter` instead of `list`\r\n this.enableFiltering = enableFiltering || null\r\n\r\n this.exec = null\r\n\r\n this.model = []\r\n\r\n // Register callback listener of any changes\r\n Object.defineProperty(this, 'list', {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return this.model\r\n },\r\n set: function (val) {\r\n this.model = val\r\n inform.call(this, this.model, this.listFilter)\r\n }\r\n })\r\n\r\n // Register callback listener of any changes with filter\r\n Object.defineProperty(this, 'listFilter', {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return !this.prop ? this.model : this.model.filter(obj => obj[this.prop] === this.value)\r\n }\r\n })\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Subscribe to the model changes (add/update/destroy)\r\n *\r\n * @param {Object} model - the model including all prototypes\r\n *\r\n */\r\n subscribe (fn) {\r\n this.exec = fn\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Add new object to the model list\r\n *\r\n * @param {Object} obj - new object to add into the model list\r\n *\r\n */\r\n add (obj) {\r\n this.list = this.list.concat({ ...obj, 'kdata-id': minId() })\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Update existing object in the model list\r\n *\r\n * @param {String} lookupId - lookup id property name of the object\r\n * @param {Object} updateObj - the updated properties\r\n *\r\n */\r\n update (updateObj) {\r\n this.list = this.list.map(obj =>\r\n notEqual(obj, updateObj) ? obj : updateObj\r\n )\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Filter the model data by selected properties, constructor\r\n * instantiation should be apply with boolean true as argument\r\n * to enable filtering\r\n * @param {String} prop - property of the object\r\n * @param {String|Boolean|Interger} value - property value\r\n *\r\n */\r\n filter (prop, value) {\r\n this.prop = prop\r\n this.value = value\r\n this.list = this.list.map(obj => obj)\r\n }\r\n\r\n /**\r\n * @private\r\n * @description\r\n * Removed existing object in the model list\r\n *\r\n * @param {String} lookupId - lookup id property name of the object\r\n * @param {String} objId - unique identifier of the lookup id\r\n *\r\n */\r\n destroy (destroyObj) {\r\n this.list = this.list.filter(obj =>\r\n notEqual(obj, destroyObj)\r\n )\r\n }\r\n}\r\n\r\nexport {\r\n createModel,\r\n html,\r\n assert,\r\n checkNodeAvailability,\r\n genId,\r\n getId,\r\n minId\r\n}\r\n","import ternaryOps from './ternaryOps'\r\n\r\nconst re = new RegExp(/(\\schecked=\")(.*?)(?=\")/g)\r\n\r\nlet tmpl = ''\r\nlet rep\r\nlet isTernary\r\nlet i\r\nlet len\r\nlet match\r\n\r\nexport default (string, obj) => {\r\n const arrProps = string.match(/{{([^{}]+)}}/g)\r\n tmpl = string\r\n for (i = 0, len = arrProps.length; i < len; i++) {\r\n rep = arrProps[i].replace(/{{([^{}]+)}}/g, '$1')\r\n isTernary = ternaryOps.call(obj, rep)\r\n if (isTernary) {\r\n tmpl = tmpl.replace('{{' + rep + '}}', isTernary.value)\r\n } else {\r\n tmpl = tmpl.replace('{{' + rep + '}}', obj[rep])\r\n }\r\n\r\n match = tmpl.match(re)\r\n if (match) {\r\n if (match[0].length === 17) { tmpl = tmpl.replace(' checked=\"checked\"', ' checked') } else { tmpl = tmpl.replace(' checked=\"\"', '') }\r\n }\r\n }\r\n return tmpl\r\n}\r\n","import templateParse from './templateParse/index'\r\nimport strInterpreter from './strInterpreter'\r\n\r\nconst DELAY = 1\r\n\r\nconst morpher = function () {\r\n genElement.call(this)\r\n // exec life-cycle componentDidUpdate\r\n if (this.componentDidUpdate && typeof this.componentDidUpdate === 'function') {\r\n this.componentDidUpdate()\r\n }\r\n}\r\n\r\nlet timer = {}\r\n\r\nconst updateContext = function (fn, delay) {\r\n timer[this.ID] = timer[this.ID] || null\r\n clearTimeout(timer[this.ID])\r\n timer[this.ID] = setTimeout(() => fn.call(this), delay)\r\n}\r\n\r\nconst nextState = function (i) {\r\n let self = this\r\n let state\r\n let value\r\n if (i < stateList.length) {\r\n state = stateList[i]\r\n value = this[state]\r\n\r\n // if value is undefined, likely has object notation we convert it to array\r\n if (value === undefined) value = strInterpreter(state)\r\n\r\n if (value && Array.isArray(value)) {\r\n // using split object notation as base for state update\r\n let inVal = this[value[0]][value[1]]\r\n\r\n Object.defineProperty(this[value[0]], value[1], {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return inVal\r\n },\r\n set: function (val) {\r\n inVal = val\r\n updateContext.call(self, morpher, DELAY)\r\n }\r\n })\r\n } else {\r\n // handle parent state update if the state is not an object\r\n Object.defineProperty(this, state, {\r\n enumerable: false,\r\n configurable: true,\r\n get: function () {\r\n return value\r\n },\r\n set: function (val) {\r\n value = val\r\n updateContext.call(self, morpher, DELAY)\r\n }\r\n })\r\n }\r\n i++\r\n nextState.call(this, i)\r\n }\r\n}\r\n\r\nconst setState = function () {\r\n nextState.call(this, 0)\r\n}\r\n\r\nlet stateList = []\r\n\r\nconst clearState = () => {\r\n stateList = []\r\n}\r\n\r\nconst addState = state => {\r\n if (stateList.indexOf(state) === -1) { stateList = stateList.concat(state) }\r\n}\r\n\r\nconst genElement = function () {\r\n this.base = this.__pristineFragment__.cloneNode(true)\r\n templateParse(this, addState, null, null, null, 'initial')\r\n templateParse(this, addState, null, null, null, 'update')\r\n templateParse(this, null, null, null, null, 'event')\r\n templateParse(this, null, null, null, null, 'diff')\r\n}\r\n\r\nexport {\r\n genElement,\r\n addState,\r\n setState,\r\n clearState,\r\n updateContext,\r\n morpher\r\n}\r\n","\r\n/**\r\n * Keetjs v4.0.0 Alpha release: https://github.com/keetjs/keet\r\n * Minimalist view layer for the web\r\n *\r\n * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Keetjs >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n *\r\n * Copyright 2018, Shahrul Nizam Selamat\r\n * Released under the MIT License.\r\n */\r\n\r\nimport parseStr from './src/components/parseStr'\r\nimport { updateContext, morpher } from './src/components/genElement'\r\nimport { genId, assert, html, createModel } from './utils'\r\nimport mount from './src/base/mount'\r\n\r\n// window.l = console.log.bind(console)\r\n// window.tr = console.trace.bind(console)\r\n\r\n/**\r\n * @description\r\n * The main constructor of Keet\r\n *\r\n * Basic Usage :-\r\n *\r\n * const App extends Keet {}\r\n * const app = new App()\r\n * app.mount('hello world').link('app')\r\n *\r\n */\r\nclass Keet {\r\n constructor () {\r\n this.ID = Keet.indentity\r\n }\r\n\r\n // generate ID for the component\r\n static get indentity () {\r\n return genId()\r\n }\r\n\r\n mount (instance) {\r\n return mount.call(this, instance)\r\n }\r\n\r\n link (id) {\r\n // The target DOM where the rendering will took place.\r\n if (!id) assert(id, 'No id is given as parameter.')\r\n this.el = id\r\n this.render()\r\n return this\r\n }\r\n\r\n render (stub) {\r\n // life-cycle method before rendering the component\r\n if (this.componentWillMount && typeof this.componentWillMount === 'function') {\r\n this.componentWillMount()\r\n }\r\n\r\n // Render this component to the target DOM\r\n if (stub) {\r\n this.IS_STUB = true\r\n }\r\n parseStr.call(this, stub)\r\n }\r\n\r\n callBatchPoolUpdate () {\r\n // force component to update, if any state / non-state\r\n // value changed DOM diffing will occur\r\n updateContext.call(this, morpher, 1)\r\n }\r\n\r\n subscribe (fn) {\r\n this.exec = fn\r\n }\r\n\r\n inform (model) {\r\n this.exec && typeof this.exec === 'function' && this.exec(model)\r\n }\r\n}\r\n\r\nexport default Keet\r\n\r\n// export {\r\n// Keet as default,\r\n// html,\r\n// createModel\r\n// }\r\n"]}
\ No newline at end of file
diff --git a/keet.js b/keet.js
index ca599ba..7757626 100644
--- a/keet.js
+++ b/keet.js
@@ -1,3 +1,4 @@
+
/**
* Keetjs v4.0.0 Alpha release: https://github.com/keetjs/keet
* Minimalist view layer for the web
@@ -13,8 +14,8 @@ import { updateContext, morpher } from './src/components/genElement'
import { genId, assert, html, createModel } from './utils'
import mount from './src/base/mount'
-window.l = console.log.bind(console)
-window.tr = console.trace.bind(console)
+// window.l = console.log.bind(console)
+// window.tr = console.trace.bind(console)
/**
* @description
diff --git a/markdown.config.js b/markdown.config.js
index 6c097cf..89a16bc 100644
--- a/markdown.config.js
+++ b/markdown.config.js
@@ -75,7 +75,7 @@ function next(i, files){
parse[file] = ''
rd.on('line', function (line) {
- if(!line.match('//rem')){
+ if(!line.match('// rem')){
if(line.match(/\.\.\/\'/g)){
line = line.replace(/\.\.\/\'/, 'keet\'')
} else if(line.match(/\.\.\/utils/g)){
@@ -120,7 +120,9 @@ function ReadLine2 (file) {
c++
if (c > 0 && c < 11) {
info += line + '\n'
+
if (c === 10) {
+ console.log(info)
var data = fs.readFileSync('./keet-min.js'); //read existing contents into data
var fd = fs.openSync('./keet-min.js', 'w+');
var buffer = new Buffer(info);
diff --git a/package.json b/package.json
index e4141bc..8f68bdf 100644
--- a/package.json
+++ b/package.json
@@ -81,7 +81,7 @@
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"start": "webpack-dev-server -d",
"test": "mocha test/test.js --require babel-core/register --require jsdom-global/register --timeout 10000",
- "test-ci": "nyc npm run test",
+ "test-ci": "nyc npm run test && npm run lint",
"lint": "standard keet.js utils.js src/**/*.js examples/**/*.js --fix"
},
"git_branch": "master",