Comparing version 0.5.1 to 0.5.2
@@ -1,3 +0,3 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Bee=t()}}(function(){return function t(e,n,i){function r(a,o){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!o&&c)return c(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[a]={exports:{}};e[a][0].call(h.exports,function(t){var n=e[a][1][t];return r(n?n:t)},h,h.exports,t,e,n,i)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(t,e,n){"use strict";function i(t){t&&(this.prefix=t)}function r(t,e){b(t)?e=t:(e=e||{},t&&(e.$tpl=t));var n={$data:k(!0,{},this.constructor.defaults),$refs:{},$mixins:[],$el:this.$el||null,$tpl:this.$tpl||"<div>{{> $content }}</div>",$content:this.$content||null,$isReplace:!1,$parent:null,$root:this,_watchers:{},_assignments:null,_relativePath:[],__links:[],_isRendered:!1},i=[n].concat(this.$mixins).concat(e.$mixins).concat([e]);i.forEach(function(t){var e;for(var n in t)t.hasOwnProperty(n)&&(n in j&&g(t[n])?(e=k({},this[n],t[n]),this[n]=k(t[n],e)):this[n]=n in _?c.afterFn(this[n],t[n]):t[n])}.bind(this)),k(this,this.$data),a.call(this),this.$beforeInit(),this.$el.bee=this,this.__links=this.__links.concat(v.walk.call(this,this.$el)),this._isRendered=!0,this.$afterInit()}function s(t,e){var n;this.$beforeUpdate(this.$data),1===arguments.length?e=t:n=[t],n||(n=g(e)?Object.keys(e):["$data"]);for(var i,r=0;i=n[r];r++)this.$update(i,!0);this.$afterUpdate(this.$data)}function a(){var t,e=this.$el,n=this.$content,i=this.$tpl;n=e&&e.childNodes?e.childNodes:n,e&&(n=e.childNodes),n&&(this.$content=p.createContent(n)),c.isObject(i)?(t=i,i=t.outerHTML):t=p.createContent(i).childNodes[0],e?this.$isReplace?(e.parentNode&&e.parentNode.replaceChild(t,e),e=t):e.appendChild(t):e=t,this.$el=e}var o=t("./env.js").document,c=t("./utils.js"),u=t("./class.js"),h=t("./directive.js"),f=t("./component.js"),l=t("./watcher.js"),d=t("./directives"),p=t("./dom-utils.js"),v=t("./check-binding.js"),m=t("./scope"),y=h.Directive,g=c.isObject,b=c.isPlainObject,$=c.parseKeyPath,x=c.deepSet,k=c.extend,w=c.create,j={$data:1},_={$beforeInit:c.noop,$afterInit:c.noop,$beforeUpdate:c.noop,$afterUpdate:c.noop,$beforeDestroy:c.noop,$afterDestroy:c.noop};k(r,{extend:c.afterFn(u.extend,c.noop,function(t){t.directives=k(w(this.directives),t.directives),t.components=k(w(this.components),t.components),t.filters=k(w(this.filters),t.filters),t.defaults=k(!0,{},this.defaults,t.defaults)}),utils:c},y,f,{setPrefix:i,directive:h.directive,prefix:"",doc:o,directives:{},components:{},defaults:{},filters:{json:function(t,e,n){return JSON.stringify(t,e,n)}},filter:function(t,e){this.filters[t]=e},mount:function(t,e){var n,i,s,a=t.nodeType?t:o.getElementById(t),c=h.getDirs(a,this);return s=c.filter(function(t){return"tag"===t.type||"component"===t.type})[0],s&&(i=this.getComponent(s.path)),e=e||{},i?(e.$data=k(p.getAttrs(a),e.$data),n=new i(k({$el:a,$isReplace:!0,__mountcall:!0},e))):n=new r(a,e),n}}),r.setPrefix("b-");for(var N in d)r.directive(N,d[N]);k(r.prototype,_,{$get:function(t){var e=new y("$get",{path:t,watch:!1});return e.parse(),e.getValue(this,!1)},$set:function(t,e){var n=this;1===arguments.length?(g(t)?(k(this.$data,t),k(this,t)):this.$data=t,s.call(n,t)):this.$replace(t,e)},$replace:function(t,e){var n,i,r,a,o=!1,c=this;1===arguments.length?(e=t,a="$data",n=[a]):(o=!0,r=m.reformScope(this,t),a=r.path,c=r.vm,n=$(a)),i=c.$get(a),"$data"===n[0]?"$data"===a?(g(this.$data)&&Object.keys(this.$data).forEach(function(t){delete this[t]}.bind(this)),k(c,e)):x(n.shift().join("."),e,c):x(a,e,c.$data),x(a,e,c),o?s.call(c,a,k({},i,e)):s.call(c,k({},i,e))},$update:function(t,e){e=e!==!1;for(var n,i,r=$(t.replace(/^\$data\./,""));n=r.join(".");){i=this._watchers[n]||[];for(var s=0,a=i.length;a>s;s++)i[s].update();if(!e)break;r.pop(),r.length||"$data"===n||r.push("$data")}l.getWatchers(this,t).forEach(function(t){t.update()}.bind(this)),e&&this.$parent&&this._relativePath.forEach(function(t){this.$parent.$update(t)}.bind(this))},$watch:function(t,e,n){if(e){var i=e.bind(this);return i._originFn=e,l.addWatcher.call(this,new y("$watch",{path:t,update:i,immediate:!!n}))}},$unwatch:function(t,e){l.unwatch(this,t,e)},$destroy:function(t){this.$beforeDestroy(),this.__links.forEach(function(t){t.unwatch()}),t&&this.$el.parentNode&&this.$el.parentNode.removeChild(this.$el),this.__links=[],this.$afterDestroy()}}),r.version="0.5.0",e.exports=r},{"./check-binding.js":3,"./class.js":4,"./component.js":5,"./directive.js":6,"./directives":12,"./dom-utils.js":18,"./env.js":19,"./scope":23,"./utils.js":25,"./watcher.js":26}],2:[function(t,e,n){},{}],3:[function(t,e,n){"use strict";function i(t){var e,n=[];if(t.nodeType===d.FRAGMENT&&(t=t.childNodes),"length"in t&&h.isUndefined(t.nodeType)){for(var a=0;a<t.length;a++)n=n.concat(i.call(this,t[a]));return n}switch(t.nodeType){case d.ELEMENT:break;case d.COMMENT:return n;case d.TEXT:return n=n.concat(s.call(this,t))}if("template"===t.nodeName.toLowerCase()&&!t.content)for(t.content=f.createDocumentFragment();t.childNodes[0];)t.content.appendChild(t.childNodes[0]);if(e=r.call(this,t),n=n.concat(e.watchers),e.terminal)return n;"template"===t.nodeName.toLowerCase()&&(n=n.concat(i.call(this,t.content)));for(var o,c=t.firstChild;c;)o=c.nextSibling,n=n.concat(i.call(this,c)),c=o;return n}function r(t){for(var e,n,i=this.constructor,r=l.getDirs(t,i),s=[],o={},c=0,u=r.length;u>c&&(e=r[c],e.dirs=r,!(n>e.priority));c++)t.removeAttribute(e.nodeName),s=s.concat(a.call(this,e)),e.terminal&&(o.terminal=!0,n=e.priority);return o.watchers=s,o}function s(t){var e=[];if(u.hasToken(t.nodeValue)){var n,i,r=u.parseToken(t.nodeValue),o=r.textMap,c=t.parentNode,d=this.constructor.directives;o.length>1?(o.forEach(function(n){var i=f.createTextNode(n);c.insertBefore(i,t),e=e.concat(s.call(this,i))}.bind(this)),c.removeChild(t)):(n=r[0],p.test(n.path)?(n.path=n.path.replace(p,""),i=h.create(d.content),i.dirName=i.type,i.anchors=l.setAnchors(t,i.type)):i=h.create(n.escape?d.text:d.html),e=a.call(this,h.extend(i,n,{el:t})))}return e}function a(t){var e;if(t.replace){var n=t.el;t.node=h.isFunction(t.replace)?t.replace():f.createTextNode(""),t.el=t.el.parentNode,t.el.replaceChild(t.node,n)}return t.vm=this,t.link(),e=c.addWatcher.call(this,t),e?[e]:[]}function o(t){t.forEach(function(t){t.unwatch()})}var c=t("./watcher"),u=t("./token.js"),h=t("./utils"),f=t("./env.js").document,l=t("./directive"),d={ELEMENT:1,ATTR:2,TEXT:3,COMMENT:8,FRAGMENT:11};f.createElement("template");var p=/^>\s*/;e.exports={walk:i,unBinding:o}},{"./directive":6,"./env.js":19,"./token.js":24,"./utils":25,"./watcher":26}],4:[function(t,e,n){var i=t("./utils.js").extend,r={extend:function(t,e){t=t||{};var n=t.hasOwnProperty("constructor")?t.constructor:function(){return r.apply(this,arguments)},r=this,s=function(){this.constructor=n},a={__super__:r.prototype};return s.prototype=r.prototype,n.prototype=new s,i(n.prototype,a,t),i(n,r,a,e),n}};e.exports=r},{"./utils.js":25}],5:[function(t,e,n){"use strict";function i(t,e,n){var i=this.components=this.components||{};return this.doc.createElement(t),s.isObject(e)&&(e=this.extend(e,n)),i[t]=e}function r(t){var e=s.parseKeyPath(t),n=this;return e.forEach(function(t){n=n&&n.components[t]}),n||null}var s=t("./utils.js");n.tag=n.component=i,n.getComponent=r},{"./utils.js":25}],6:[function(t,e,n){"use strict";function i(t,e){var n=this.directives=this.directives||{};return n[t]=new r(t,e)}function r(t,e){this.type=t,c.extend(this,e)}function s(t,e){var n,i,r,s,h,f=[],l=(t.parentNode,t.nodeName.toLowerCase()),p=e.directives,m=e.prefix;e.getComponent(l)&&t.setAttribute(m+"component",l);for(var y=t.attributes.length-1;y>=0;y--)n=t.attributes[y],i=n.nodeName,r=i.slice(m.length),s={el:t,node:n,nodeName:i,path:n.value},h=null,0===i.indexOf(m)&&(h=a(r,p))?h.dirName=r:u.hasToken(n.value)?u.parseToken(n.value).forEach(function(t){t.dirName=0===i.indexOf(m)?r:i,f.push(c.extend(d(p.attr),s,t))}):v.test(i)&&(h=c.extend(d(p.attr),{dirName:i.replace(v,""),conditional:!0})),h&&(h.anchor&&(h.anchors=o(t,h.dirName)),f.push(c.extend(h,s)));return f.sort(function(t,e){return e.priority-t.priority}),f}function a(t,e){var n,i;for(var r in e){if(t===r){n=e[r];break}if(0===t.indexOf(r+"-")){n=e[r],n.sub?i=t.slice(r.length+1):n=null;break}}return n&&(n=d(n),n.subType=i),n}function o(t,e){var n=t.parentNode,i={};return i.start=h.createComment(e+" start"),n.insertBefore(i.start,t),i.end=h.createComment(e+" end"),t.nextSibling?n.insertBefore(i.end,t.nextSibling):n.appendChild(i.end),i}var c=t("./utils.js"),u=t("./token.js"),h=t("./env.js").document,f=t("./parse.js").parse,l=t("./eval.js"),d=(t("./dom-utils"),c.create),p={};r.prototype={priority:0,type:"",subType:"",sub:!1,link:c.noop,unLink:c.noop,update:c.noop,tearDown:c.noop,terminal:!1,replace:!1,watch:!0,immediate:!0,anchor:!1,anchors:null,getNodes:function(t,e){t=t||this.anchors.start,e=e||this.anchors.end;var n=[],i=t.nextSibling;if(this.anchor&&i){for(;i!==e;)n.push(i),i=i.nextSibling;return n}},parse:function(){var t=p[this.path];if(t&&t._type===this.type)this.ast=t;else try{this.ast=f(this.path,this.type),this.ast._type=this.type,p[this.path]=this.ast}catch(e){this.ast={},e.message='SyntaxError in "'+this.path+'" | '+e.message,console.error(e)}},getValue:function(t,e){e=e!==!1;var n;try{n=l.eval(this.ast,t,this)}catch(i){n="",console.error(i)}return e&&(c.isUndefined(n)||null===n)&&(n=""),n}};var v=/\?$/;e.exports={Directive:r,directive:i,getDirs:s,setAnchors:o}},{"./dom-utils":18,"./env.js":19,"./eval.js":20,"./parse.js":22,"./token.js":24,"./utils.js":25}],7:[function(t,e,n){"use strict";function i(t,e,n){try{(e in t||"class"===e)&&("style"===e&&t.style.setAttribute?t.style.setAttribute("cssText",n):"class"===e?t.className=n:t[e]="boolean"==typeof t[e]?!0:n)}catch(i){}t.setAttribute(e,n)}function r(t,e){t.removeAttribute(e)}t("../utils.js");e.exports={link:function(){this.dirName===this.type?this.attrs={}:this.update("")},update:function(t){var e=this.el,n={};if(this.dirName===this.type){for(var s in t)i(e,s,t[s]),delete this.attrs[s],n[s]=!0;for(var s in this.attrs)r(e,s);this.attrs=n}else this.conditional?t?i(e,this.dirName,t):r(e,this.dirName):(this.textMap[this.position]=t&&t+"",i(e,this.dirName,this.textMap.join("")))}}},{"../utils.js":25}],8:[function(t,e,n){"use strict";e.exports={link:function(){this.initClass=this.el.className||"",this.keys={}},update:function(t){var e=this.initClass,n=this.watcher;if("string"==typeof t)t&&(e+=" "+t);else for(var i in t)this.keys[i]||(this.keys[i]=!0,this.vm.$watch(i,function(){n.update()})),this.vm.$get(i)&&(e+=" "+t[i]);this.el.className=e}}},{}],9:[function(t,e,n){var i=t("../utils.js"),r=t("../dom-utils"),s=t("../check-binding");e.exports={priority:-1,watch:!1,unLink:function(){this.component&&this.component.$destroy()},link:function(){var t,e=this.vm,n=this.el,a=e.constructor,o=[],c={},u=a.getComponent(this.path);if(u){if(u===a&&e.__mountcall||n.bee&&n.bee===e)return;return o=this.dirs,o=o.filter(function(t){return"attr"==t.type||"with"==t.type}),o.forEach(function(n){var r,s;r=n.path,"with"===n.type?i.extend(c,e.$get(r)):(s=i.hyphenToCamel(n.dirName),c[s]=e.$get(r)),e.$watch(r,function(e){t&&(e=n.textMap?n.textMap.join(""):e,s?t.$set(s,e):t.$set(e))})}),e.__links=e.__links.concat(s.walk.call(e,n.childNodes)),this.component=t=new u({$el:n,$isReplace:!0,$data:i.extend({},u.prototype.$data,c,r.getAttrs(n))}),n.bee=t,t}console.warn("Component: "+this.path+" not defined! Ignore")}}},{"../check-binding":3,"../dom-utils":18,"../utils.js":25}],10:[function(t,e,n){"use strict";var i=t("../dom-utils"),r=t("../check-binding");e.exports={replace:!0,anchor:!0,link:function(){this.watchers=[]},unLink:function(){this.watchers.forEach(function(t){t.unwatch()})},update:function(t){var e=this.getNodes(),n=this.anchors.end.parentNode;e.forEach(function(t){n.removeChild(t)}),this.unLink();var s=i.createContent(t);this.watchers=r.walk.call(this.vm,s),n.insertBefore(s,this.anchors.end)}}},{"../check-binding":3,"../dom-utils":18}],11:[function(t,e,n){"use strict";var i=t("../check-binding"),r=(t("../dom-utils"),t("../env").document);e.exports={anchor:!0,priority:900,terminal:!0,link:function(){this.watchers=[],this.el.content?(this.frag=this.el.content,this.el.parentNode.removeChild(this.el)):this.frag=r.createDocumentFragment(),this.remove()},update:function(t){t?this.state||this.add():this.state&&this.remove(),this.state=t},add:function(){var t=this.anchors.end;this.walked||(this.walked=!0,this.watchers=i.walk.call(this.vm,this.frag)),this.watchers.forEach(function(t){t._hide=!1,t._needUpdate&&(t.update(),t._needUpdate=!1)}),t.parentNode&&t.parentNode.insertBefore(this.frag,t)},remove:function(){for(var t=this.getNodes(),e=0,n=t.length;n>e;e++)this.frag.appendChild(t[e]);this.watchers.forEach(function(t){t._hide=!0})}}},{"../check-binding":3,"../dom-utils":18,"../env":19}],12:[function(t,e,n){"use strict";var i=t("../env.js").document,r=t("../utils.js"),s=(t("../check-binding"),{});s.text={terminal:!0,replace:!0,update:function(t){this.node.nodeValue=r.isUndefined(t)?"":t}},s.html={terminal:!0,replace:!0,link:function(){this.nodes=[]},update:function(t){var e=i.createElement("div");e.innerHTML=r.isUndefined(t)?"":t;for(var n;n=this.nodes.pop();)n.parentNode&&n.parentNode.removeChild(n);for(var s=e.childNodes;n=s[0];)this.nodes.push(n),this.el.insertBefore(n,this.node)}},s.template={priority:1e4,watch:!1,link:function(){for(var t=this.el.childNodes,e=i.createDocumentFragment();t[0];)e.appendChild(t[0]);this.el.content=e}},s.src={update:function(t){this.el.src=t}},s["with"]={},s["if"]=t("./if"),s.repeat=t("./repeat"),s.attr=t("./attr"),s.model=t("./model"),s.style=t("./style"),s.on=t("./on"),s.component=s.tag=t("./component"),s.content=t("./content"),s.ref=t("./ref"),s["class"]=t("./class.js"),e.exports=s},{"../check-binding":3,"../env.js":19,"../utils.js":25,"./attr":7,"./class.js":8,"./component":9,"./content":10,"./if":11,"./model":13,"./on":14,"./ref":15,"./repeat":16,"./style":17}],13:[function(t,e,n){"use strict";var i=t("../utils.js"),r=t("../token.js").hasToken,s=t("../event-bind.js");e.exports={teminal:!0,priority:-2,link:function(){var t=this.path,e=this.vm;if(!t)return!1;var n,a=this.el,o="change",c=n="value",u=i.isUndefined(e.$get(t)),h=/\r\n/g,f=function(t){0===t&&"checkbox"!==a.type&&(t="0");var e=(t||"")+"",t=a[n];t&&t.replace&&(t=t.replace(h,"\n")),e!==t&&(a[n]=e)},l=function(){var n=a[c];n.replace&&(n=n.replace(h,"\n")),e.$set(t,n)},d=function(t){t&&t.propertyName&&t.propertyName!==n||l.apply(this,arguments)},p=i.ie;if(a.bee)a=a.bee,c=a.$valuekey,c&&(f=function(t){a.$replace(c,t)},l=function(){e.$replace(t,a.$get(c))},a.$watch(c,function(t,e){t!==e&&l()},!0));else{switch(a.tagName){default:c=n="innerHTML";case"INPUT":case"TEXTAREA":switch(a.type){case"checkbox":c=n="checked",p&&(o+=" click");break;case"radio":n="checked",p&&(o+=" click"),f=function(t){a.checked=a.value===t+""},u=a.checked;break;default:e.$lazy||("oninput"in a&&(o+=" input"),p&&(o+=" keyup propertychange cut"))}break;case"SELECT":a.multiple&&(l=function(){for(var n=[],i=0,r=a.options.length;r>i;i++)a.options[i].selected&&n.push(a.options[i].value);e.$replace(t,n)},f=function(t){if(t&&t.length)for(var e=0,n=a.options.length;n>e;e++)a.options[e].selected=-1!==t.indexOf(a.options[e].value)}),u=u&&!r(a[c])}o.split(/\s+/g).forEach(function(t){s.removeEvent(a,t,d),s.addEvent(a,t,d)}),a[c]&&u&&l()}this.update=f}}},{"../event-bind.js":21,"../token.js":24,"../utils.js":25}],14:[function(t,e,n){"use strict";function i(t,e,n){return function(i){var r=i.target||i.srcElement,a=e?s.toArray(t.el.querySelectorAll(e)):[r];do if(a.indexOf(r)>=0)return i.delegateTarget=r,n.call(t.vm,i);while(r=r.parentNode)}}var r=t("../event-bind.js"),s=t("../utils");e.exports={watch:!1,sub:!0,priority:-3,immediate:!1,link:function(){var t=this;this.subType?r.addEvent(this.el,this.subType,function(){t.vm.$get(t.path)}):this.immediate=!0},update:function(t){var e,n;for(var s in t)e=s.split(/\s+/),n=e.shift(),e=e.join(" "),r.addEvent(this.el,n,i(this,e,t[s]))}}},{"../event-bind.js":21,"../utils":25}],15:[function(t,e,n){var i=t("../utils");e.exports={watch:!1,priority:-2,unLink:function(){i.isArray(this.ref)?this.ref.splice(this.vm.$index,1):this.vm.$refs[this.path]=null},link:function(){var t=this.vm;t.__repeat?(t.$index||(t.$parent.$refs[this.path]=[]),this.ref=t.$parent.$refs[this.path],this.ref[t.$index]=t):t.$refs[this.path]=this.el.bee||this.el}}},{"../utils":25}],16:[function(t,e,n){"use strict";function i(t,e){var n=t.vmList[e];return n?t.isRange?n.__anchor:n.$el:t.anchors.end}function r(t,e){var n=t.vmList,i=n[e].__anchor,r=n[e+1];return[i].concat(t.getNodes(i,r&&r.__anchor))}function s(t,e){var n=c.createDocumentFragment();return t.isRange?r(t,e).forEach(function(t){n.appendChild(t)}):n.appendChild(t.vmList[e].$el),n}function a(t,e,n){var i=e.slice();return t.filter(function(t){var e,r=o(t,i,n);return 0>r?e=!0:i.splice(r,1),e})}function o(t,e,n,i){i=i||0;var r=e.indexOf(t,i);if(-1===r&&n)for(var s,a=i;s=e[a];a++)if(t[n]===s[n]&&!u.isUndefined(t[n])){r=a;break}return r}var c=t("../env.js").document,u=t("../utils.js"),h=t("../scope"),f=["splice","push","pop","shift","unshift","sort","reverse"];e.exports={priority:1e3,anchor:!0,terminal:!0,unLink:function(){this.vmList.forEach(function(t){t.$destroy()})},link:function(){for(var t=this.cstr=this.vm.constructor;t.__super__;)t=t.__super__.constructor;this.trackId=this.el.getAttribute("track-by"),this.el.removeAttribute("track-by"),this.cstr=t.extend({},this.cstr),this.cstr.defaults={},this.curArr=[],this.vmList=[],this.el.content?(this.frag=this.el.content,this.isRange=!0):this.frag=this.el,this.el.parentNode.removeChild(this.el)},update:function(t){var e=this.curArr,n=this.anchors.end.parentNode,l=this,d=this.vmList,p=this.trackId;u.isArray(t)&&(this.listPath=this.summary.paths.filter(function(t){return!u.isFunction(l.vm.$get(t))}),a(e,t,p).forEach(function(t){var i=o(t,e,p);e.splice(i,1),l.isRange?r(l,i).forEach(function(t){n.removeChild(t)}):n.removeChild(d[i].$el),d[i].$destroy(),d.splice(i,1)}),t.forEach(function(r,a){var u,h,f,v=o(r,t,p,a),m=o(r,e,p,a);0>m?(h=this.frag.cloneNode(!0),this.isRange&&(f=c.createComment(""),h.childNodes.length?h.insertBefore(f,h.childNodes[0]):h.appendChild(f)),u=new this.cstr(h,{$data:r,$index:v,$root:this.vm.$root,$parent:this.vm,_assignments:this.summary.assignments,__repeat:!0,__anchor:f}),n.insertBefore(u.$el,i(l,v)),d.splice(v,0,u),e.splice(v,0,r),u._relativePath=this.listPath):v!==m&&(n.insertBefore(s(l,m),i(l,v)),n.insertBefore(s(l,v),i(l,m+1)),d[m]=[d[v],d[v]=d[m]][0],e[m]=[e[v],e[v]=e[m]][0],d[v].$index=v,d[v].$update("$index"))}.bind(this)),d.forEach(function(t,e){t.$index=e,t.$el.$index=e,t.$update("$index",!1)}),this.summary.paths.forEach(function(t){var e=l.vm.$get(t),n=e.__dirs__;u.isArray(e)&&(n||(u.extend(e,{$set:function(t,n){e.splice(t,1,u.isObject(n)?u.extend({},e[t],n):n)},$replace:function(t,n){e.splice(t,1,n)},$remove:function(t){e.splice(t,1)}}),f.forEach(function(t){e[t]=u.afterFn(e[t],function(){n.forEach(function(t){t.listPath.forEach(function(e){var n=h.reformScope(t.vm,e);n.vm.$update(n.path)})})})}),n=e.__dirs__=[]),-1===n.indexOf(l)&&n.push(l))}))}}},{"../env.js":19,"../scope":23,"../utils.js":25}],17:[function(t,e,n){"use strict";var i=t("../utils"),r=/([A-Z])/g,s=["width","height","min-width","min-height","max-width","max-height","margin","margin-top","margin-right","margin-left","margin-bottom","padding","padding-top","padding-right","padding-bottom","padding-left","top","left","right","bottom"];e.exports={link:function(){this.initStyle=this.el.style.getAttribute?this.el.style.getAttribute("cssText"):this.el.getAttribute("style")},update:function(t){var e,n,a=this.el,o=this.initStyle?this.initStyle.replace(/;?$/,";"):"";if("string"==typeof t)o+=t;else for(var c in t)n=t[c],e=c.replace(r,function(t){return"-"+t.toLowerCase()}),s.indexOf(e)>=0&&i.isNumeric(n)&&(n+="px"),i.isUndefined(n)||(o+=e+": "+n+"; ");a.style.setAttribute?a.style.setAttribute("cssText",o):a.setAttribute("style",o)}}},{"../utils":25}],18:[function(t,e,n){"use strict";var i=t("./env.js").document,r=t("./utils");e.exports={createContent:function(t){var e,n=i.createDocumentFragment(),s=[];r.isObject(t)?t.nodeName&&t.nodeType?n.appendChild(t):"length"in t&&(s=t):(e=i.createElement("div"),e.innerHTML=(t+"").trim(),s=e.childNodes);for(;s[0];)n.appendChild(s[0]);return n},getAttrs:function(t){for(var e=t.attributes,n={},i=e.length-1;i>=0;i--)n[r.hyphenToCamel(e[i].nodeName)]=e[i].value;return n},hasAttr:function(t,e){return t.hasAttribute?t.hasAttribute(e):!r.isUndefined(t[e])}}},{"./env.js":19,"./utils":25}],19:[function(t,e,n){!function(e){"use strict";n.root=e,n.document=e.document||t("jsdom").jsdom()}(function(){return this}())},{jsdom:2}],20:[function(t,e,n){"use strict";function i(t,e,n){return t&&t.then?t.then(function(t){return e.apply(f,[t].concat(n))}):e.apply(f,[t].concat(n))}function r(t,e){return d[t][e]||function(){}}function s(t,e){c=!0,t?(f=t.$root,c=!1,a={locals:t||{},filters:t.constructor.filters||{}}):a={filters:{},locals:{}},e&&(h=e),o={filters:{},locals:{},paths:{},assignments:{}},u=""}var a,o,c,u,h,f,l=t("./scope"),d={unary:{"+":function(t){return+t},"-":function(t){return-t},"!":function(t){return!t},"[":function(t){return t},"{":function(t){for(var e={},n=0,i=t.length;i>n;n++)e[t[n][0]]=t[n][1];return e},"typeof":function(t){return typeof t},"new":function(t){return new t}},binary:{"+":function(t,e){return t+e},"-":function(t,e){return t-e},"*":function(t,e){return t*e},"/":function(t,e){return t/e},"%":function(t,e){return t%e},"<":function(t,e){return e>t},">":function(t,e){return t>e},"<=":function(t,e){return e>=t},">=":function(t,e){return t>=e},"==":function(t,e){return t==e},"!=":function(t,e){return t!=e},"===":function(t,e){return t===e},"!==":function(t,e){return t!==e},"&&":function(t,e){return t&&e},"||":function(t,e){return t||e},",":function(t,e){return e},".":function(t,e){return e&&u&&(u=u+"."+e),t[e]},"[":function(t,e){return"undefined"!=typeof e&&u&&(u=u+"."+e),t[e]},"(":function(t,e){return t.apply(f,e)},"|":function(t,e){return i(t,e,[])},"new":function(t,e){return t===Date?new Function("return new Date("+e.join(", ")+")")():new(Function.prototype.bind.apply(t,e))},"in":function(t,e){return this.repeat?e:t in e},catchby:function(t,e){return t["catch"]?t["catch"](e.bind(f)):(c||console.error("catchby expect a promise"),t)}},ternary:{"?":function(t,e,n){return t?e:n},"(":function(t,e,n){return t[e].apply(t,n)},"|":function(t,e,n){return i(t,e,n)}}},p=["first","second","third"],v=function(t){for(var e,n,i=t.arity,s=t.value,c=[],h=0;3>h;h++)if(e=t[p[h]])if(Array.isArray(e)){c[h]=[];for(var f=0,l=e.length;l>f;f++)c[h].push("undefined"==typeof e[f].key?v(e[f]):[e[f].key,v(e[f])])}else c[h]=v(e);switch("literal"!==i&&(u&&"."!==s&&"["!==s&&(o.paths[u]=!0),"name"===i&&(u=s)),i){case"unary":case"binary":case"ternary":try{n=r(i,s).apply(t,c)}catch(d){}break;case"literal":n=s;break;case"repeat":o.assignments[s]=!0;break;case"name":o.locals[s]=!0,n=m(s,a.locals);break;case"filter":o.filters[s]=!0,n=a.filters[s];break;case"this":n=a.locals}return n},m=function(t,e){var n=l.reformScope(e,t);return n.vm[n.path]};n.eval=function(t,e,n){return s(e||{},n),v(t)},n.summary=function(t){s(),v(t),u&&(o.paths[u]=!0);for(var e in o)o[e]=Object.keys(o[e]);return o}},{"./scope":23}],21:[function(t,e,n){"use strict";n.addEvent=function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)},n.removeEvent=function(t,e,n){t.removeEventListener?t.removeEventListener(e,n):t.detachEvent("on"+e,n)}},{}],22:[function(t,e,n){"use strict";var i,r=Object.create||function(t){function e(){}return e.prototype=t,new e},s=function(t,e){e=e||this;var n=t+=" But found '"+e.value+"'"+(e.from?" at "+e.from:"")+" in '"+i+"'",r=new Error(n);throw r.name=e.name="SyntaxError",e.message=t,r},a=function(t,e,n){var i,r,a,o,c,u=0,h=t.length,f=[],l=function(t,e){return{type:t,value:e,from:r,to:u}};if(t){for(i=t.charAt(u);i;)if(r=u," ">=i)u+=1,i=t.charAt(u);else if(i>="a"&&"z">=i||i>="A"&&"Z">=i||"$"===i||"_"===i){for(c=i,u+=1;i=t.charAt(u),i>="a"&&"z">=i||i>="A"&&"Z">=i||i>="0"&&"9">=i||"_"===i;)c+=i,u+=1;f.push(l("name",c))}else if(i>="0"&&"9">=i){for(c=i,u+=1;i=t.charAt(u),!("0">i||i>"9");)u+=1,c+=i;if("."===i)for(u+=1,c+=i;i=t.charAt(u),!("0">i||i>"9");)u+=1,c+=i;if("e"===i||"E"===i){u+=1,c+=i,i=t.charAt(u),("-"===i||"+"===i)&&(u+=1,c+=i,i=t.charAt(u)),("0">i||i>"9")&&s("Bad exponent",l("number",c));do u+=1,c+=i,i=t.charAt(u);while(i>="0"&&"9">=i)}i>="a"&&"z">=i&&(c+=i,u+=1,s("Bad number",l("number",c))),a=+c,isFinite(a)?f.push(l("number",a)):s("Bad number",l("number",c))}else if("'"===i||'"'===i){for(c="",o=i,u+=1;i=t.charAt(u)," ">i&&(l("string",c),s("\n"===i||"\r"===i||""===i?"Unterminated string.":"Control character in string.",l("",c))),i!==o;){if("\\"===i)switch(u+=1,u>=h&&s("Unterminated string",l("string",c)),i=t.charAt(u)){case"b":i="\b";break;case"f":i="\f";break;case"n":i="\n";break;case"r":i="\r";break;case"t":i=" ";break;case"u":u>=h&&s("Unterminated string",l("string",c)),i=parseInt(t.substr(u+1,4),16),(!isFinite(i)||0>i)&&s("Unterminated string",l("string",c)),i=String.fromCharCode(i),u+=4}c+=i,u+=1}u+=1,f.push(l("string",c)),i=t.charAt(u)}else if(e.indexOf(i)>=0){for(c=i,u+=1;;){if(i=t.charAt(u),u>=h||n.indexOf(i)<0)break;c+=i,u+=1}f.push(l("operator",c))}else u+=1,f.push(l("operator",i)),i=t.charAt(u);return f}},o=function(t){t=t||{};var e,n,o,c,u={},h=function(){return this},f=function(t){return t.nud=h,t.led=null,t.std=null,t.lbp=0,t},l=function(t){var i,a,c,h;return t&&e.id!==t&&s("Expected '"+t+"'.",e),o>=n.length?void(e=u["(end)"]):(c=n[o],o+=1,h=c.value,i=c.type,("operator"===i||"string"!==i)&&h in u?(a=u[h],a||s("Unknown operator.",c)):"name"===i?a=f(c):"string"===i||"number"===i||"regexp"===i?(a=u["(literal)"],i="literal"):s("Unexpected token.",c),e=r(a),e.from=c.from,e.to=c.to,e.value=h,e.arity=i,e)},d=function(t){var n,i=e;for(l(),n=i.nud();t<e.lbp;)i=e,l(),n=i.led(n);return n},p={nud:function(){s("Undefined.",this)},led:function(t){s("Missing operator.",this)}},v=function(t,e){var n=u[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):(n=r(p),n.id=n.value=t,n.lbp=e,u[t]=n),n},m=function(t,e,n){var i=v(t);return i.nud=function(){return this.value=u[this.id].value,this.arity="literal",this},i.value=e,i},y=function(t,e,n){var i=v(t,e);return i.led=n||function(t){return this.first=t,this.second=d(e),this.arity="binary",this},i},g=function(t,e,n){var i=v(t,e);return i.led=n||function(t){return this.first=t,this.second=d(e-1),this.arity="binary",this},i},b=function(t,e){var n=v(t);return n.nud=e||function(){return this.first=d(70),this.arity="unary",this},n};v("(end)"),v("(name)"),v(":"),v(")"),v("]"),v("}"),v(","),m("true",!0),m("false",!1),m("null",null),m("undefined"),m("Math",Math),m("Date",Date);for(var $ in t)m($,t[$]);return v("(literal)").nud=h,v("this").nud=function(){return this.arity="this",this},y("?",20,function(t){return this.first=t,this.second=d(0),l(":"),this.third=d(0),this.arity="ternary",this}),g("&&",31),g("||",30),g("===",40),g("!==",40),g("==",40),g("!=",40),g("<",40),g("<=",40),g(">",40),g(">=",40),y("in",45,function(t){return this.first=t,this.second=d(0),this.arity="binary","repeat"===c&&(t.arity="repeat",this.repeat=!0),this}),y("+",50),y("-",50),y("*",60),y("/",60),y("%",60),y("(",75,function(t){var n=[];if("."===t.id||"["===t.id?(this.arity="ternary",this.first=t.first,this.second=t.second,this.third=n):(this.arity="binary",this.first=t,this.second=n,"unary"===t.arity&&"function"===t.id||"name"===t.arity||"literal"===t.arity||"("===t.id||"&&"===t.id||"||"===t.id||"?"===t.id||s("Expected a variable name.",t)),")"!==e.id)for(;;){if(n.push(d(1)),","!==e.id)break;l(",")}return l(")"),this}),y(".",80,function(t){return this.first=t,"name"!==e.arity&&s("Expected a property name.",e),e.arity="literal",this.second=e,this.arity="binary",l(),this}),y("[",60,function(t){return this.first=t,this.second=d(0),this.arity="binary",l("]"),this}),y("|",10,function(t){var n;if(this.first=t,e.arity="filter",this.second=d(10),this.arity="binary",":"===e.id)for(this.arity="ternary",this.third=n=[];;)if(l(":"),n.push(d(10)),":"!==e.id)break;return this}),y("catchby",10),b("!"),b("-"),b("typeof"),b("(",function(){var t=d(0);return l(")"),t}),b("[",function(){var t=[];if("]"!==e.id)for(;;){if(t.push(d(1)),","!==e.id)break;l(",")}return l("]"),this.first=t,this.arity="unary",this}),b("{",function(){var t,n,i=[];if("}"!==e.id)for(;;){if(t=e,"name"!==t.arity&&"literal"!==t.arity&&s("Bad property name: ",e),l(),l(":"),n=d(1),n.key=t.value,i.push(n),","!==e.id)break;l(",")}return l("}"),this.first=i,this.arity="unary",this}),b("new",function(){var t=[];if(this.first=d(79),"("===e.id){for(l("("),this.arity="binary",this.second=t;;){if(t.push(d(1)),","!==e.id)break;l(",")}l(")")}else this.arity="unary";return this}),function(t,e){i=t,n=a(t,"=<>!+-*&|/%^","=<>&|"),o=0,c=e,l();var r=d(0);return l("(end)"),r}};n.parse=o()},{}],23:[function(t,e,n){"use strict";var i=t("./utils"),r=function(t,e){for(var n,r=i.parseKeyPath(e),s=t,a=r[0],o=s;s;){if(o=s,n=s._assignments,s.__repeat)if(n&&n.length){if("$index"===a||"$parent"===a)break;if(a===n[0]){1===r.length?r[0]="$data":r.shift();break}}else if(e in s)break;s=s.$parent}return{vm:o,path:r.join(".")}};n.reformScope=r},{"./utils":25}],24:[function(t,e,n){function i(t){return s.lastIndex=0,t&&s.test(t)}function r(t){var e,n,i=[],r=[],a=0;for(s.lastIndex=0;e=s.exec(t);)s.lastIndex-a>e[0].length&&r.push(t.slice(a,s.lastIndex-e[0].length)),n={escape:!e[2],path:(e[2]||e[1]).trim(),position:r.length,textMap:r},i.push(n),r.push(e[0]),a=s.lastIndex;return t.length>a&&r.push(t.slice(a,t.length)),i.textMap=r,i}var s=/{{({([^}\n]+)}|[^}\n]+)}}/g;n.hasToken=i,n.parseToken=r},{}],25:[function(t,e,n){"use strict";function i(t){return t.replace(o,"").split(a)}function r(){var t,e,n,i,s,a,o=arguments[0]||{},c=1,u=arguments.length,h=!1;for("boolean"==typeof o&&(h=o,o=arguments[c]||{},c++),"object"==typeof o||f.isFunction(o)||(o={});u>c;c++)if(null!=(t=arguments[c]))for(e in t)if("prototype"!==e)if(n=o[e],i=t[e],h&&i&&(f.isPlainObject(i)||(s=f.isArray(i)))){if(o===i)continue;s?(s=!1,a=n&&f.isArray(n)?n:[]):a=n&&f.isPlainObject(n)?n:{},o[e]=r(h,a,i)}else f.isUndefined(i)||"string"==typeof o||(o[e]=i);return o}var s=t("./env.js").document,a=/(?:\.|\[)/g,o=/\]/g,c=Object.create||function(t){function e(){}return e.prototype=t,new e},u=/-(-?)([a-z])/gi,h=function(t){return t.replace(u,function(t,e,n){return e?e+n:n.toUpperCase()})},f={noop:function(){},ie:!!s.attachEvent,isObject:function(t){return"object"==typeof t&&null!==t},isUndefined:function(t){return"undefined"==typeof t},isFunction:function(t){return"function"==typeof t},isArray:function(t){return f.ie?t&&t.constructor+""==Array+"":Array.isArray(t)},isNumeric:function(t){return!f.isArray(t)&&t-parseFloat(t)+1>=0},isPlainObject:function(t){return!t||"[object Object]"!=={}.toString.call(t)||t.nodeType||t===t.window?!1:!0},beforeFn:function(t,e,n){return function(){var i=e.apply(this,arguments);return n&&n.call(this,i)?i:t.apply(this,arguments)}},afterFn:function(t,e,n){return function(){var i=t.apply(this,arguments);return n&&n.call(this,i)?i:(e.apply(this,arguments),i)}},parseKeyPath:i,deepSet:function(t,e,n){if(t){var s=i(t),a=n;s.forEach(function(t,n){n===s.length-1?a[t]=e:a&&a.hasOwnProperty(t)?a=a[t]:(a[t]={},a=a[t])})}else r(n,e);return n},extend:r,create:c,toArray:function(t){var e=[];try{e=Array.prototype.slice.call(t)}catch(n){for(var i=0,r=t.length;r>i;i++)e[i]=t[i]}return e},hyphenToCamel:h};e.exports=f},{"./env.js":19 | ||
}],26:[function(t,e,n){"use strict";function i(t,e){var n,i,r=t,s=[],a=f[e.path];e.watcher=this,this.state=1,this.dir=e,this.vm=t,this.watchers=[],this.val=0/0,e.parse(),a&&a._type===e.type||(a=o.summary(e.ast),a._type=e.type,f[e.path]=a),e.summary=a;for(var c=0,u=e.summary.paths.length;u>c;c++)n=h(t,e.summary.paths[c]),r=n.vm,i=n.path,e.watch?(r._watchers[i]=r._watchers[i]||[],r._watchers[i].push(this),s=r._watchers[i]):s=[this],this.watchers.push(s);e.immediate!==!1&&this.update()}function r(t,e,n){var i;try{i=o.summary(u(e))}catch(r){r.message='SyntaxError in "'+e+'" | '+r.message,console.error(r)}i.paths.forEach(function(e){for(var i,r=t._watchers[e]||[],s=r.length-1;s>=0;s--)i=r[s].dir.update,(i===n||i._originFn===n)&&r[s].unwatch()})}function s(t){return t.path?new i(this,t):void 0}function a(t){var e=this.val;this.val=t,this.dir.update(t,e)}var o=t("./eval.js"),c=t("./utils.js"),u=t("./parse.js").parse,h=t("./scope").reformScope,f={};i.unwatch=r,i.addWatcher=s,i.getWatchers=function(t,e){var n,i=t._watchers,r=[];for(var s in i)n=s.charAt(e.length),0===s.indexOf(e)&&"."===n&&(r=r.concat(i[s]));return r},c.extend(i.prototype,{update:function(){var t,e=this;return this._hide?void(this._needUpdate=!0):(t=this.dir.getValue(this.vm),void((t!==this.val||c.isObject(t))&&(t&&t.then?t.then(function(t){a.call(e,t)}):a.call(this,t))))},unwatch:function(){this.watchers.forEach(function(t){for(var e=t.length-1;e>=0;e--)t[e]===this&&(this.state&&(t[e].dir.unLink(),this.state=0),t.splice(e,1))}.bind(this)),this.watchers=[]}}),e.exports=i},{"./eval.js":20,"./parse.js":22,"./scope":23,"./utils.js":25}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Bee=t()}}(function(){return function t(e,n,i){function r(a,o){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!o&&c)return c(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[a]={exports:{}};e[a][0].call(h.exports,function(t){var n=e[a][1][t];return r(n?n:t)},h,h.exports,t,e,n,i)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(t,e,n){},{}],2:[function(t,e,n){"use strict";function i(t){t&&(this.prefix=t)}function r(t,e){b(t)?e=t:(e=e||{},t&&(e.$tpl=t));var n={$data:x(!0,{},this.constructor.defaults),$refs:{},$mixins:[],$el:this.$el||null,$tpl:this.$tpl||"<div>{{> $content }}</div>",$content:this.$content||null,$isReplace:!1,$parent:null,$root:this,_watchers:{},_assignments:null,_relativePath:[],__links:[],_isRendered:!1},i=[n].concat(this.$mixins).concat(e.$mixins).concat([e]);i.forEach(function(t){var e;for(var n in t)t.hasOwnProperty(n)&&(n in j&&g(t[n])?(e=x({},this[n],t[n]),this[n]=x(t[n],e)):this[n]=n in _?c.afterFn(this[n],t[n]):t[n])}.bind(this)),x(this,this.$data),a.call(this),this.$beforeInit(),this.$el.bee=this,this.__links=this.__links.concat(v.walk.call(this,this.$el)),this._isRendered=!0,this.$afterInit()}function s(t,e){var n;this.$beforeUpdate(this.$data),1===arguments.length?e=t:n=[t],n||(n=g(e)?Object.keys(e):["$data"]);for(var i,r=0;i=n[r];r++)this.$update(i,!0);this.$afterUpdate(this.$data)}function a(){var t,e=this.$el,n=this.$content,i=this.$tpl;n=e&&e.childNodes?e.childNodes:n,e&&(n=e.childNodes),n&&(this.$content=p.createContent(n)),c.isObject(i)?(t=i,i=t.outerHTML):t=p.createContent(i).childNodes[0],e?this.$isReplace?(e.parentNode&&e.parentNode.replaceChild(t,e),e=t):e.appendChild(t):e=t,this.$el=e}var o=t("./env.js").document,c=t("./utils.js"),u=t("./class.js"),h=t("./directive.js"),l=t("./component.js"),f=t("./watcher.js"),d=t("./directives"),p=t("./dom-utils.js"),v=t("./check-binding.js"),m=t("./scope"),y=h.Directive,g=c.isObject,b=c.isPlainObject,$=c.parseKeyPath,k=c.deepSet,x=c.extend,w=c.create,j={$data:1},_={$beforeInit:c.noop,$afterInit:c.noop,$beforeUpdate:c.noop,$afterUpdate:c.noop,$beforeDestroy:c.noop,$afterDestroy:c.noop};x(r,{extend:c.afterFn(u.extend,c.noop,function(t,e){var n=e[1]||{};t.directives=x(w(this.directives),n.directives),t.components=x(w(this.components),n.components),t.filters=x(w(this.filters),n.filters),t.defaults=x(!0,{},this.defaults,n.defaults)}),utils:c},y,l,{setPrefix:i,directive:h.directive,prefix:"",doc:o,directives:{},components:{},defaults:{},filters:{json:function(t,e,n){return JSON.stringify(t,e,n)}},filter:function(t,e){this.filters[t]=e},mount:function(t,e){var n,i,r,s=t.nodeType?t:o.getElementById(t),a=h.getDirs(s,this);return r=a.filter(function(t){return"tag"===t.type||"component"===t.type})[0],r&&(i=this.getComponent(r.path)),e=e||{},i?(e.$data=x(p.getAttrs(s),e.$data),n=new i(x({$el:s,$isReplace:!0,__mountcall:!0},e))):n=new this(s,e),n}}),r.setPrefix("b-");for(var N in d)r.directive(N,d[N]);x(r.prototype,_,{$get:function(t){var e=new y("$get",{path:t,watch:!1});return e.parse(),e.getValue(this,!1)},$set:function(t,e){var n=this;1===arguments.length?(g(t)?(x(this.$data,t),x(this,t)):this.$data=t,s.call(n,t)):this.$replace(t,e)},$replace:function(t,e){var n,i,r,a,o=!1,c=this;1===arguments.length?(e=t,a="$data",n=[a]):(o=!0,r=m.reformScope(this,t),a=r.path,c=r.vm,n=$(a)),i=c.$get(a),"$data"===n[0]?"$data"===a?(g(this.$data)&&Object.keys(this.$data).forEach(function(t){delete this[t]}.bind(this)),x(c,e)):k(n.shift().join("."),e,c):k(a,e,c.$data),k(a,e,c),o?s.call(c,a,x({},i,e)):s.call(c,x({},i,e))},$update:function(t,e){e=e!==!1;for(var n,i,r=$(t.replace(/^\$data\./,""));n=r.join(".");){i=this._watchers[n]||[];for(var s=0,a=i.length;a>s;s++)i[s]&&i[s].update();if(!e)break;r.pop(),r.length||"$data"===n||r.push("$data")}f.getWatchers(this,t).forEach(function(t){t.update()}.bind(this)),e&&this.$parent&&this._relativePath.forEach(function(t){this.$parent.$update(t)}.bind(this))},$watch:function(t,e,n){if(e){var i=e.bind(this);return i._originFn=e,f.addWatcher.call(this,new y("$watch",{path:t,update:i,immediate:!!n}))}},$unwatch:function(t,e){f.unwatch(this,t,e)},$destroy:function(t){this.$beforeDestroy(),this.__links.forEach(function(t){t.unwatch()}),t&&this.$el.parentNode&&this.$el.parentNode.removeChild(this.$el),this.__links=[],this.$afterDestroy()}}),r.version="0.5.2",e.exports=r},{"./check-binding.js":3,"./class.js":4,"./component.js":5,"./directive.js":6,"./directives":12,"./dom-utils.js":18,"./env.js":19,"./scope":23,"./utils.js":25,"./watcher.js":26}],3:[function(t,e,n){"use strict";function i(t){var e,n=[];if(t.nodeType===d.FRAGMENT&&(t=t.childNodes),"length"in t&&h.isUndefined(t.nodeType)){for(var a=0;a<t.length;a++)n=n.concat(i.call(this,t[a]));return n}switch(t.nodeType){case d.ELEMENT:break;case d.COMMENT:return n;case d.TEXT:return n=n.concat(s.call(this,t))}if("template"===t.nodeName.toLowerCase()&&!t.content)for(t.content=l.createDocumentFragment();t.childNodes[0];)t.content.appendChild(t.childNodes[0]);if(e=r.call(this,t),n=n.concat(e.watchers),e.terminal)return n;"template"===t.nodeName.toLowerCase()&&(n=n.concat(i.call(this,t.content)));for(var o,c=t.firstChild;c;)o=c.nextSibling,n=n.concat(i.call(this,c)),c=o;return n}function r(t){for(var e,n,i=this.constructor,r=f.getDirs(t,i),s=[],o={},c=0,u=r.length;u>c&&(e=r[c],e.dirs=r,!(n>e.priority));c++)t.removeAttribute(e.nodeName),s=s.concat(a.call(this,e)),e.terminal&&(o.terminal=!0,n=e.priority);return o.watchers=s,o}function s(t){var e=[];if(u.hasToken(t.nodeValue)){var n,i,r=u.parseToken(t.nodeValue),o=r.textMap,c=t.parentNode,d=this.constructor.directives;o.length>1?(o.forEach(function(n){var i=l.createTextNode(n);c.insertBefore(i,t),e=e.concat(s.call(this,i))}.bind(this)),c.removeChild(t)):(n=r[0],p.test(n.path)?(n.path=n.path.replace(p,""),i=h.create(d.content),i.dirName=i.type,i.anchors=f.setAnchors(t,i.type)):i=h.create(n.escape?d.text:d.html),e=a.call(this,h.extend(i,n,{el:t})))}return e}function a(t){var e;if(t.replace){var n=t.el;t.node=h.isFunction(t.replace)?t.replace():l.createTextNode(""),t.el=t.el.parentNode,t.el.replaceChild(t.node,n)}return t.vm=this,t.link(),e=c.addWatcher.call(this,t),e?[e]:[]}function o(t){t.forEach(function(t){t.unwatch()})}var c=t("./watcher"),u=t("./token.js"),h=t("./utils"),l=t("./env.js").document,f=t("./directive"),d={ELEMENT:1,ATTR:2,TEXT:3,COMMENT:8,FRAGMENT:11};l.createElement("template");var p=/^>\s*/;e.exports={walk:i,unBinding:o}},{"./directive":6,"./env.js":19,"./token.js":24,"./utils":25,"./watcher":26}],4:[function(t,e,n){var i=t("./utils.js").extend,r={extend:function(t,e){t=t||{};var n=t.hasOwnProperty("constructor")?t.constructor:function(){return r.apply(this,arguments)},r=this,s=function(){this.constructor=n},a={__super__:r.prototype};return s.prototype=r.prototype,n.prototype=new s,i(n.prototype,a,t),i(n,r,a,e),n}};e.exports=r},{"./utils.js":25}],5:[function(t,e,n){"use strict";function i(t,e,n){var i=this.components=this.components||{};return this.doc.createElement(t),s.isObject(e)&&(e=this.extend(e,n)),i[t]=e}function r(t){var e=s.parseKeyPath(t),n=this;return e.forEach(function(t){n=n&&n.components[t]}),n||null}var s=t("./utils.js");n.tag=n.component=i,n.getComponent=r},{"./utils.js":25}],6:[function(t,e,n){"use strict";function i(t,e){var n=this.directives=this.directives||{};return n[t]=new r(t,e)}function r(t,e){this.type=t,c.extend(this,e)}function s(t,e){var n,i,r,s,h,l=[],f=(t.parentNode,t.nodeName.toLowerCase()),p=e.directives,m=e.prefix;e.getComponent(f)&&t.setAttribute(m+"component",f);for(var y=t.attributes.length-1;y>=0;y--)n=t.attributes[y],i=n.nodeName,r=i.slice(m.length),s={el:t,node:n,nodeName:i,path:n.value},h=null,0===i.indexOf(m)&&(h=a(r,p))?h.dirName=r:u.hasToken(n.value)?u.parseToken(n.value).forEach(function(t){t.dirName=0===i.indexOf(m)?r:i,l.push(c.extend(d(p.attr),s,t))}):v.test(i)&&(h=c.extend(d(p.attr),{dirName:i.replace(v,""),conditional:!0})),h&&(h.anchor&&(h.anchors=o(t,h.dirName)),l.push(c.extend(h,s)));return l.sort(function(t,e){return e.priority-t.priority}),l}function a(t,e){var n,i;for(var r in e){if(t===r){n=e[r];break}if(0===t.indexOf(r+"-")){n=e[r],n.sub?i=t.slice(r.length+1):n=null;break}}return n&&(n=d(n),n.subType=i),n}function o(t,e){var n=t.parentNode,i={};return i.start=h.createComment(e+" start"),n.insertBefore(i.start,t),i.end=h.createComment(e+" end"),t.nextSibling?n.insertBefore(i.end,t.nextSibling):n.appendChild(i.end),i}var c=t("./utils.js"),u=t("./token.js"),h=t("./env.js").document,l=t("./parse.js").parse,f=t("./eval.js"),d=(t("./dom-utils"),c.create),p={};r.prototype={priority:0,type:"",subType:"",sub:!1,link:c.noop,unLink:c.noop,update:c.noop,tearDown:c.noop,terminal:!1,replace:!1,watch:!0,immediate:!0,anchor:!1,anchors:null,getNodes:function(t,e){t=t||this.anchors.start,e=e||this.anchors.end;var n=[],i=t.nextSibling;if(this.anchor&&i){for(;i!==e;)n.push(i),i=i.nextSibling;return n}},parse:function(){var t=p[this.path];if(t&&t._type===this.type)this.ast=t;else{"attr"==this.type&&this.escape===!1&&(this.path="{"+this.path+"}");try{this.ast=l(this.path,this.type),this.ast._type=this.type,p[this.path]=this.ast}catch(e){this.ast={},e.message='SyntaxError in "'+this.path+'" | '+e.message,console.error(e)}}},getValue:function(t,e){e=e!==!1;var n;try{n=f.eval(this.ast,t,this)}catch(i){n="",console.error(i)}return e&&(c.isUndefined(n)||null===n)&&(n=""),n}};var v=/\?$/;e.exports={Directive:r,directive:i,getDirs:s,setAnchors:o}},{"./dom-utils":18,"./env.js":19,"./eval.js":20,"./parse.js":22,"./token.js":24,"./utils.js":25}],7:[function(t,e,n){"use strict";function i(t,e,n){a(this)?t.bee.$set(o.hyphenToCamel(e),n):s(t,e,n)}function r(t,e,n){a(this)?t.bee.$set(o.hyphenToCamel(e),n):t.removeAttribute(e)}function s(t,e,n){try{(e in t||"class"===e)&&("style"===e&&t.style.setAttribute?t.style.setAttribute("cssText",n):"class"===e?t.className=n:t[e]="boolean"==typeof t[e]?!0:n)}catch(i){}t.setAttribute(e,n)}function a(t){var e=t.el.bee;return e&&!e.__repeat&&e!=t.vm}var o=t("../utils.js");e.exports={link:function(){this.dirName===this.type?this.attrs={}:this.update("")},update:function(t){var e=this.el,n={},s=this.textMap;if(this.dirName===this.type){for(var a in t)i.call(this,e,a,t[a]),delete this.attrs[a],n[a]=!0;for(var a in this.attrs)r.call(this,e,a);this.attrs=n}else this.conditional?t?i.call(this,e,this.dirName,t):r.call(this,e,this.dirName):(s[this.position]=t,i.call(this,e,this.dirName,s.length>1?s.join(""):s[0]))}}},{"../utils.js":25}],8:[function(t,e,n){"use strict";e.exports={link:function(){this.initClass=this.el.className||"",this.keys={}},update:function(t){var e=this.initClass,n=this.watcher;if("string"==typeof t)t&&(e+=" "+t);else for(var i in t)this.keys[i]||(this.keys[i]=!0,this.vm.$watch(i,function(){n.update()})),this.vm.$get(i)&&(e+=" "+t[i]);this.el.className=e}}},{}],9:[function(t,e,n){function i(t){var e,n=t.textMap;return e=n&&n.length>1?n.join(""):n[0],r.isPlainObject(e)?r.extend(!0,{},e):e}var r=t("../utils.js"),s=t("../dom-utils"),a=t("../check-binding");e.exports={priority:-1,watch:!1,unLink:function(){this.component&&this.component.$destroy()},link:function(){var t,e,n=this.vm,o=this.el,c=n.constructor,u={},h=c.getComponent(this.path),l={};if(h){if(h===c&&n.__mountcall||o.bee&&o.bee===n)return;e=this.dirs.filter(function(t){return"attr"==t.type||"with"==t.type}),e.forEach(function(e){var s,a;s=e.path,"with"===e.type?(r.extend(!0,u,n.$get(s)),n.$watch(s,function(e){t&&t.$set(r.extend({},n.$get(s)))})):(a=r.hyphenToCamel(e.dirName),u[a]=i(e),e.el.removeAttribute(e.dirName))}),n.__links=n.__links.concat(a.walk.call(n,o.childNodes)),l=s.getAttrs(o);var f;for(var d in l)f=r.camelToHyphen(d),f=f.slice(n.constructor.prefix.length),f in n.constructor.directives&&delete l[d];return this.component=t=new h({$el:o,$isReplace:!0,$data:r.extend(!0,{},u,l)}),o.bee=t,t}console.error("Component: "+this.path+" not defined!")}}},{"../check-binding":3,"../dom-utils":18,"../utils.js":25}],10:[function(t,e,n){"use strict";var i=t("../dom-utils"),r=t("../check-binding");e.exports={replace:!0,anchor:!0,link:function(){this.watchers=[]},unLink:function(){this.watchers.forEach(function(t){t.unwatch()})},update:function(t){var e=this.getNodes(),n=this.anchors.end.parentNode;e.forEach(function(t){n.removeChild(t)}),this.unLink();var s=i.createContent(t);this.watchers=r.walk.call(this.vm,s),n.insertBefore(s,this.anchors.end)}}},{"../check-binding":3,"../dom-utils":18}],11:[function(t,e,n){"use strict";var i=t("../check-binding"),r=(t("../dom-utils"),t("../env").document);e.exports={anchor:!0,priority:900,terminal:!0,link:function(){this.watchers=[],this.el.content?(this.frag=this.el.content,this.el.parentNode.removeChild(this.el)):this.frag=r.createDocumentFragment(),this.remove()},update:function(t){t?this.state||this.add():this.state&&this.remove(),this.state=t},add:function(){var t=this.anchors.end;this.walked||(this.walked=!0,this.watchers=i.walk.call(this.vm,this.frag)),this.watchers.forEach(function(t){t._hide=!1,t._needUpdate&&(t.update(),t._needUpdate=!1)}),t.parentNode&&t.parentNode.insertBefore(this.frag,t)},remove:function(){for(var t=this.getNodes(),e=0,n=t.length;n>e;e++)this.frag.appendChild(t[e]);this.watchers.forEach(function(t){t._hide=!0})}}},{"../check-binding":3,"../dom-utils":18,"../env":19}],12:[function(t,e,n){"use strict";var i=t("../env.js").document,r=t("../utils.js"),s=(t("../check-binding"),{});s.text={terminal:!0,replace:!0,update:function(t){this.node.nodeValue=r.isUndefined(t)?"":t}},s.html={terminal:!0,replace:!0,link:function(){this.nodes=[]},update:function(t){var e=i.createElement("div");e.innerHTML=r.isUndefined(t)?"":t;for(var n;n=this.nodes.pop();)n.parentNode&&n.parentNode.removeChild(n);for(var s=e.childNodes;n=s[0];)this.nodes.push(n),this.el.insertBefore(n,this.node)}},s.template={priority:1e4,watch:!1,link:function(){for(var t=this.el.childNodes,e=i.createDocumentFragment();t[0];)e.appendChild(t[0]);this.el.content=e}},s.src={update:function(t){this.el.src=t}},s["with"]={},s["if"]=t("./if"),s.repeat=t("./repeat"),s.attr=t("./attr"),s.model=t("./model"),s.style=t("./style"),s.on=t("./on"),s.component=s.tag=t("./component"),s.content=t("./content"),s.ref=t("./ref"),s["class"]=t("./class.js"),e.exports=s},{"../check-binding":3,"../env.js":19,"../utils.js":25,"./attr":7,"./class.js":8,"./component":9,"./content":10,"./if":11,"./model":13,"./on":14,"./ref":15,"./repeat":16,"./style":17}],13:[function(t,e,n){"use strict";var i=t("../utils.js"),r=t("../token.js").hasToken,s=t("../event-bind.js"),a=t("../check-binding");e.exports={teminal:!0,priority:-2,link:function(){var t=this.path,e=this.vm;if(!t)return!1;var n,o=this.el,c="change",u=n="value",h=i.isUndefined(e.$get(t)),l=/\r\n/g,f=function(t){0===t&&"checkbox"!==o.type&&(t="0");var e=(t||"")+"",t=o[n];t&&t.replace&&(t=t.replace(l,"\n")),e!==t&&(o[n]=e)},d=function(){var n=o[u];n.replace&&(n=n.replace(l,"\n")),e.$set(t,n)},p=function(t){t&&t.propertyName&&t.propertyName!==n||d.apply(this,arguments)},v=i.ie;if(o.bee)o=o.bee,u=o.$valuekey,u&&(f=function(t){o.$replace(u,t)},d=function(){e.$replace(t,o.$get(u))},o.$watch(u,function(t,e){t!==e&&d()},!0));else{switch(e.__links=e.__links.concat(a.walk.call(e,o.childNodes)),o.tagName){default:u=n="innerHTML";case"INPUT":case"TEXTAREA":switch(o.type){case"checkbox":u=n="checked",v&&(c+=" click");break;case"radio":n="checked",v&&(c+=" click"),f=function(t){o.checked=o.value===t+""},h=o.checked;break;default:e.$lazy||("oninput"in o&&(c+=" input"),v&&(c+=" keyup propertychange cut"))}break;case"SELECT":o.multiple&&(d=function(){for(var n=[],i=0,r=o.options.length;r>i;i++)o.options[i].selected&&n.push(o.options[i].value);e.$replace(t,n)},f=function(t){if(t&&t.length)for(var e=0,n=o.options.length;n>e;e++)o.options[e].selected=-1!==t.indexOf(o.options[e].value)}),h=h&&!r(o[u])}c.split(/\s+/g).forEach(function(t){s.removeEvent(o,t,p),s.addEvent(o,t,p)}),o[u]&&h&&d()}this.update=f}}},{"../check-binding":3,"../event-bind.js":21,"../token.js":24,"../utils.js":25}],14:[function(t,e,n){"use strict";function i(t,e,n){return function(i){var r=i.target||i.srcElement,a=e?s.toArray(t.el.querySelectorAll(e)):[r];do if(a.indexOf(r)>=0)return i.delegateTarget=r,n.call(t.vm,i);while(r=r.parentNode)}}var r=t("../event-bind.js"),s=t("../utils");e.exports={watch:!1,sub:!0,priority:-3,immediate:!1,link:function(){var t=this;this.subType?r.addEvent(this.el,this.subType,function(){t.vm.$get(t.path)}):this.immediate=!0},update:function(t){var e,n;for(var s in t)e=s.split(/\s+/),n=e.shift(),e=e.join(" "),r.addEvent(this.el,n,i(this,e,t[s]))}}},{"../event-bind.js":21,"../utils":25}],15:[function(t,e,n){var i=t("../utils");e.exports={watch:!1,priority:-2,unLink:function(){i.isArray(this.ref)?this.ref.splice(this.vm.$index,1):this.vm.$refs[this.path]=null},link:function(){var t=this.vm;t.__repeat?(t.$index||(t.$parent.$refs[this.path]=[]),this.ref=t.$parent.$refs[this.path],this.ref[t.$index]=t):t.$refs[this.path]=this.el.bee||this.el}}},{"../utils":25}],16:[function(t,e,n){"use strict";function i(t,e){var n=t.vmList[e];return n?t.isRange?n.__anchor:n.$el:t.anchors.end}function r(t,e){var n=t.vmList,i=n[e].__anchor,r=n[e+1];return[i].concat(t.getNodes(i,r&&r.__anchor))}function s(t,e){var n=c.createDocumentFragment();return t.isRange?r(t,e).forEach(function(t){n.appendChild(t)}):n.appendChild(t.vmList[e].$el),n}function a(t,e,n){var i=e.slice();return t.filter(function(t){var e,r=o(t,i,n);return 0>r?e=!0:i.splice(r,1),e})}function o(t,e,n,i){i=i||0;var r=e.indexOf(t,i);if(-1===r&&n)for(var s,a=i;s=e[a];a++)if(t[n]===s[n]&&!u.isUndefined(t[n])){r=a;break}return r}var c=t("../env.js").document,u=t("../utils.js"),h=t("../scope"),l=["splice","push","pop","shift","unshift","sort","reverse"];e.exports={priority:1e3,anchor:!0,terminal:!0,unLink:function(){this.vmList.forEach(function(t){t.$destroy()})},link:function(){var e=t("../bee");this.trackId=this.el.getAttribute("track-by"),this.el.removeAttribute("track-by"),this.cstr=e.extend({},this.vm.constructor),this.cstr.defaults={},this.curArr=[],this.vmList=[],this.el.content?(this.frag=this.el.content,this.isRange=!0):this.frag=this.el,this.el.parentNode.removeChild(this.el)},update:function(t){var e=this.curArr,n=this.anchors.end.parentNode,f=this,d=this.vmList,p=this.trackId,v=[];u.isArray(t)&&(this.listPath=this.summary.paths.filter(function(t){return!u.isFunction(f.vm.$get(t))}),a(e,t,p).forEach(function(t){var i=o(t,e,p);e.splice(i,1),f.isRange?r(f,i).forEach(function(t){n.removeChild(t)}):n.removeChild(d[i].$el),d[i].$destroy(),d.splice(i,1)}),t.forEach(function(r,a){var u,h,l,v=o(r,t,p,a),m=o(r,e,p,a);0>m?(h=this.frag.cloneNode(!0),this.isRange&&(l=c.createComment(""),h.childNodes.length?h.insertBefore(l,h.childNodes[0]):h.appendChild(l)),u=new this.cstr(h,{$data:r,$index:v,$root:this.vm.$root,$parent:this.vm,_assignments:this.summary.assignments,__repeat:!0,__anchor:l}),n.insertBefore(u.$el,i(f,v)),d.splice(v,0,u),e.splice(v,0,r),u._relativePath=this.listPath):v!==m&&(n.insertBefore(s(f,m),i(f,v)),n.insertBefore(s(f,v),i(f,m+1)),d[m]=[d[v],d[v]=d[m]][0],e[m]=[e[v],e[v]=e[m]][0],d[v].$index=v,d[v].$update("$index"))}.bind(this)),d.forEach(function(t,e){t.$index=e,t.$el.$index=e,t.$update("$index",!1)}),this.listPath.forEach(function(t){var e=f.vm.$get(t);u.isArray(e)&&v.push(e)}),v.push(t),v.forEach(function(t){var e=t.__dirs__;e||(u.extend(t,{$set:function(e,n){t.splice(e,1,u.isObject(n)?u.extend({},t[e],n):n)},$replace:function(e,n){t.splice(e,1,n)},$remove:function(e){t.splice(e,1)}}),l.forEach(function(n){t[n]=u.afterFn(t[n],function(){e.forEach(function(t){t.listPath.forEach(function(e){var n=h.reformScope(t.vm,e);n.vm.$update(n.path)})})})}),e=t.__dirs__=[]),-1===e.indexOf(f)&&e.push(f)}))}}},{"../bee":2,"../env.js":19,"../scope":23,"../utils.js":25}],17:[function(t,e,n){"use strict";var i=t("../utils"),r=["width","height","min-width","min-height","max-width","max-height","margin","margin-top","margin-right","margin-left","margin-bottom","padding","padding-top","padding-right","padding-bottom","padding-left","top","left","right","bottom"];e.exports={link:function(){this.initStyle=this.el.style.getAttribute?this.el.style.getAttribute("cssText"):this.el.getAttribute("style")},update:function(t){var e,n,s=this.el,a=this.initStyle?this.initStyle.replace(/;?$/,";"):"";if("string"==typeof t)a+=t;else for(var o in t)n=t[o],e=i.camelToHyphen(o),r.indexOf(e)>=0&&i.isNumeric(n)&&(n+="px"),i.isUndefined(n)||(a+=e+": "+n+"; ");s.style.setAttribute?s.style.setAttribute("cssText",a):s.setAttribute("style",a)}}},{"../utils":25}],18:[function(t,e,n){"use strict";var i=t("./env.js").document,r=t("./utils");e.exports={createContent:function(t){var e,n=i.createDocumentFragment(),s=[];r.isObject(t)?t.nodeName&&t.nodeType?n.appendChild(t):"length"in t&&(s=t):(e=i.createElement("div"),e.innerHTML=(t+"").trim(),s=e.childNodes);for(;s[0];)n.appendChild(s[0]);return n},getAttrs:function(t){for(var e=t.attributes,n={},i=e.length-1;i>=0;i--)n[r.hyphenToCamel(e[i].nodeName)]=e[i].value;return n},hasAttr:function(t,e){return t.hasAttribute?t.hasAttribute(e):!r.isUndefined(t[e])}}},{"./env.js":19,"./utils":25}],19:[function(t,e,n){!function(e){"use strict";n.root=e,n.document=e.document||t("jsdom").jsdom()}(function(){return this}())},{jsdom:1}],20:[function(t,e,n){"use strict";function i(t,e,n){return t&&t.then?t.then(function(t){return e.apply(l,[t].concat(n))}):e.apply(l,[t].concat(n))}function r(t,e){return d[t][e]||function(){}}function s(t,e){c=!0,t?(l=t.$root,c=!1,a={locals:t||{},filters:t.constructor.filters||{}}):a={filters:{},locals:{}},e&&(h=e),o={filters:{},paths:{},assignments:{}},u=""}var a,o,c,u,h,l,f=t("./scope"),d={unary:{"+":function(t){return+t},"-":function(t){return-t},"!":function(t){return!t},"[":function(t){return t},"{":function(t){for(var e={},n=0,i=t.length;i>n;n++)e[t[n][0]]=t[n][1];return e},"typeof":function(t){return typeof t},"new":function(t){return new t}},binary:{"+":function(t,e){return t+e},"-":function(t,e){return t-e},"*":function(t,e){return t*e},"/":function(t,e){return t/e},"%":function(t,e){return t%e},"<":function(t,e){return e>t},">":function(t,e){return t>e},"<=":function(t,e){return e>=t},">=":function(t,e){return t>=e},"==":function(t,e){return t==e},"!=":function(t,e){return t!=e},"===":function(t,e){return t===e},"!==":function(t,e){return t!==e},"&&":function(t,e){return t&&e},"||":function(t,e){return t||e},",":function(t,e){return e},".":function(t,e){var n=this.first;return e&&u&&("binary"!==n.arity||"["!==n.value)&&(u=u+"."+e),t[e]},"[":function(t,e){return"undefined"!=typeof e&&u&&(u=u+"."+e),t[e]},"(":function(t,e){return t.apply(l,e)},"|":function(t,e){return i(t,e,[])},"new":function(t,e){return t===Date?new Function("return new Date("+e.join(", ")+")")():new(Function.prototype.bind.apply(t,e))},"in":function(t,e){return this.repeat?e:t in e},catchby:function(t,e){return t["catch"]?t["catch"](e.bind(l)):(c||console.error("catchby expect a promise"),t)}},ternary:{"?":function(t,e,n){return t?e:n},"(":function(t,e,n){return t[e].apply(t,n)},"|":function(t,e,n){return i(t,e,n)}}},p=["first","second","third"],v=function(t){for(var e,n,i=t.arity,s=t.value,c=[],h=0;3>h;h++)if(e=t[p[h]])if(Array.isArray(e)){c[h]=[];for(var l=0,f=e.length;f>l;l++)c[h].push("undefined"==typeof e[l].key?v(e[l]):[e[l].key,v(e[l])])}else c[h]=v(e);switch("literal"!==i&&(u&&"."!==s&&"["!==s&&(o.paths[u]=!0),"name"===i&&(u=s)),i){case"unary":case"binary":case"ternary":try{n=r(i,s).apply(t,c)}catch(d){}break;case"literal":n=s;break;case"repeat":o.assignments[s]=!0;break;case"name":n=m(s,a.locals);break;case"filter":o.filters[s]=!0,n=a.filters[s];break;case"this":n=a.locals}return n},m=function(t,e){var n=f.reformScope(e,t);return n.vm[n.path]};n.eval=function(t,e,n){return s(e||{},n),v(t)},n.summary=function(t){s(),v(t),u&&(o.paths[u]=!0);for(var e in o)o[e]=Object.keys(o[e]);return o}},{"./scope":23}],21:[function(t,e,n){"use strict";n.addEvent=function(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)},n.removeEvent=function(t,e,n){t.removeEventListener?t.removeEventListener(e,n):t.detachEvent("on"+e,n)}},{}],22:[function(t,e,n){"use strict";var i,r=Object.create||function(t){function e(){}return e.prototype=t,new e},s=function(t,e){e=e||this;var n=t+=" But found '"+e.value+"'"+(e.from?" at "+e.from:"")+" in '"+i+"'",r=new Error(n);throw r.name=e.name="SyntaxError",e.message=t,r},a=function(t,e,n){var i,r,a,o,c,u=0,h=t.length,l=[],f=function(t,e){return{type:t,value:e,from:r,to:u}};if(t){for(i=t.charAt(u);i;)if(r=u," ">=i)u+=1,i=t.charAt(u);else if(i>="a"&&"z">=i||i>="A"&&"Z">=i||"$"===i||"_"===i){for(c=i,u+=1;i=t.charAt(u),i>="a"&&"z">=i||i>="A"&&"Z">=i||i>="0"&&"9">=i||"_"===i;)c+=i,u+=1;l.push(f("name",c))}else if(i>="0"&&"9">=i){for(c=i,u+=1;i=t.charAt(u),!("0">i||i>"9");)u+=1,c+=i;if("."===i)for(u+=1,c+=i;i=t.charAt(u),!("0">i||i>"9");)u+=1,c+=i;if("e"===i||"E"===i){u+=1,c+=i,i=t.charAt(u),("-"===i||"+"===i)&&(u+=1,c+=i,i=t.charAt(u)),("0">i||i>"9")&&s("Bad exponent",f("number",c));do u+=1,c+=i,i=t.charAt(u);while(i>="0"&&"9">=i)}i>="a"&&"z">=i&&(c+=i,u+=1,s("Bad number",f("number",c))),a=+c,isFinite(a)?l.push(f("number",a)):s("Bad number",f("number",c))}else if("'"===i||'"'===i){for(c="",o=i,u+=1;i=t.charAt(u)," ">i&&(f("string",c),s("\n"===i||"\r"===i||""===i?"Unterminated string.":"Control character in string.",f("",c))),i!==o;){if("\\"===i)switch(u+=1,u>=h&&s("Unterminated string",f("string",c)),i=t.charAt(u)){case"b":i="\b";break;case"f":i="\f";break;case"n":i="\n";break;case"r":i="\r";break;case"t":i=" ";break;case"u":u>=h&&s("Unterminated string",f("string",c)),i=parseInt(t.substr(u+1,4),16),(!isFinite(i)||0>i)&&s("Unterminated string",f("string",c)),i=String.fromCharCode(i),u+=4}c+=i,u+=1}u+=1,l.push(f("string",c)),i=t.charAt(u)}else if(e.indexOf(i)>=0){for(c=i,u+=1;;){if(i=t.charAt(u),u>=h||n.indexOf(i)<0)break;c+=i,u+=1}l.push(f("operator",c))}else u+=1,l.push(f("operator",i)),i=t.charAt(u);return l}},o=function(t){t=t||{};var e,n,o,c,u={},h=function(){return this},l=function(t){return t.nud=h,t.led=null,t.std=null,t.lbp=0,t},f=function(t){var i,a,c,h;return t&&e.id!==t&&s("Expected '"+t+"'.",e),o>=n.length?void(e=u["(end)"]):(c=n[o],o+=1,h=c.value,i=c.type,("operator"===i||"string"!==i)&&h in u?(a=u[h],a||s("Unknown operator.",c)):"name"===i?a=l(c):"string"===i||"number"===i||"regexp"===i?(a=u["(literal)"],i="literal"):s("Unexpected token.",c),e=r(a),e.from=c.from,e.to=c.to,e.value=h,e.arity=i,e)},d=function(t){var n,i=e;for(f(),n=i.nud();t<e.lbp;)i=e,f(),n=i.led(n);return n},p={nud:function(){s("Undefined.",this)},led:function(t){s("Missing operator.",this)}},v=function(t,e){var n=u[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):(n=r(p),n.id=n.value=t,n.lbp=e,u[t]=n),n},m=function(t,e,n){var i=v(t);return i.nud=function(){return this.value=u[this.id].value,this.arity="literal",this},i.value=e,i},y=function(t,e,n){var i=v(t,e);return i.led=n||function(t){return this.first=t,this.second=d(e),this.arity="binary",this},i},g=function(t,e,n){var i=v(t,e);return i.led=n||function(t){return this.first=t,this.second=d(e-1),this.arity="binary",this},i},b=function(t,e){var n=v(t);return n.nud=e||function(){return this.first=d(70),this.arity="unary",this},n};v("(end)"),v("(name)"),v(":"),v(")"),v("]"),v("}"),v(","),m("true",!0),m("false",!1),m("null",null),m("undefined"),m("Math",Math),m("Date",Date);for(var $ in t)m($,t[$]);return v("(literal)").nud=h,v("this").nud=function(){return this.arity="this",this},y("?",20,function(t){return this.first=t,this.second=d(0),f(":"),this.third=d(0),this.arity="ternary",this}),g("&&",31),g("||",30),g("===",40),g("!==",40),g("==",40),g("!=",40),g("<",40),g("<=",40),g(">",40),g(">=",40),y("in",45,function(t){return this.first=t,this.second=d(0),this.arity="binary","repeat"===c&&(t.arity="repeat",this.repeat=!0),this}),y("+",50),y("-",50),y("*",60),y("/",60),y("%",60),y("(",75,function(t){var n=[];if("."===t.id||"["===t.id?(this.arity="ternary",this.first=t.first,this.second=t.second,this.third=n):(this.arity="binary",this.first=t,this.second=n,"unary"===t.arity&&"function"===t.id||"name"===t.arity||"literal"===t.arity||"("===t.id||"&&"===t.id||"||"===t.id||"?"===t.id||s("Expected a variable name.",t)),")"!==e.id)for(;;){if(n.push(d(1)),","!==e.id)break;f(",")}return f(")"),this}),y(".",80,function(t){return this.first=t,"name"!==e.arity&&s("Expected a property name.",e),e.arity="literal",this.second=e,this.arity="binary",f(),this}),y("[",60,function(t){return this.first=t,this.second=d(0),this.arity="binary",f("]"),this}),y("|",10,function(t){var n;if(this.first=t,e.arity="filter",this.second=d(10),this.arity="binary",":"===e.id)for(this.arity="ternary",this.third=n=[];;)if(f(":"),n.push(d(10)),":"!==e.id)break;return this}),y("catchby",10),b("!"),b("-"),b("typeof"),b("(",function(){var t=d(0);return f(")"),t}),b("[",function(){var t=[];if("]"!==e.id)for(;;){if(t.push(d(1)),","!==e.id)break;f(",")}return f("]"),this.first=t,this.arity="unary",this}),b("{",function(){var t,n,i=[];if("}"!==e.id)for(;;){if(t=e,"name"!==t.arity&&"literal"!==t.arity&&s("Bad property name: ",e),f(),f(":"),n=d(1),n.key=t.value,i.push(n),","!==e.id)break;f(",")}return f("}"),this.first=i,this.arity="unary",this}),b("new",function(){var t=[];if(this.first=d(79),"("===e.id){for(f("("),this.arity="binary",this.second=t;;){if(t.push(d(1)),","!==e.id)break;f(",")}f(")")}else this.arity="unary";return this}),function(t,e){i=t,n=a(t,"=<>!+-*&|/%^","=<>&|"),o=0,c=e,f();var r=d(0);return f("(end)"),r}};n.parse=o()},{}],23:[function(t,e,n){"use strict";var i=t("./utils"),r=function(t,e){for(var n,r=i.parseKeyPath(e),s=t,a=r[0],o=s;s;){if(o=s,n=s._assignments,s.__repeat)if(n&&n.length){if("$index"===a||"$parent"===a)break;if(a===n[0]){1===r.length?r[0]="$data":r.shift();break}}else if(e in s)break;s=s.$parent}return{vm:o,path:r.join(".")}};n.reformScope=r},{"./utils":25}],24:[function(t,e,n){function i(t){return s.lastIndex=0,t&&s.test(t)}function r(t){var e,n,i=[],r=[],a=0;for(s.lastIndex=0;e=s.exec(t);)s.lastIndex-a>e[0].length&&r.push(t.slice(a,s.lastIndex-e[0].length)),n={escape:!e[2],path:(e[2]||e[1]).trim(),position:r.length,textMap:r},i.push(n),r.push(e[0]),a=s.lastIndex;return t.length>a&&r.push(t.slice(a,t.length)),i.textMap=r,i}var s=/{{({(.+?)}|.+?)}}/g;n.hasToken=i,n.parseToken=r},{}],25:[function(t,e,n){"use strict";function i(t){return t.replace(o,"").split(a)}function r(){var t,e,n,i,s,a,o=arguments[0]||{},c=1,u=arguments.length,h=!1;for("boolean"==typeof o&&(h=o,o=arguments[c]||{},c++),"object"==typeof o||d.isFunction(o)||(o={});u>c;c++)if(null!=(t=arguments[c]))for(e in t)if("prototype"!==e)if(n=o[e],i=t[e],h&&i&&(d.isPlainObject(i)||(s=d.isArray(i)))){if(o===i)continue;s?(s=!1,a=n&&d.isArray(n)?n:[]):a=n&&d.isPlainObject(n)?n:{},o[e]=r(h,a,i)}else d.isUndefined(i)||"string"==typeof o||(o[e]=i);return o}var s=t("./env.js").document,a=/(?:\.|\[)/g,o=/\]/g,c=Object.create||function(t){function e(){}return e.prototype=t,new e},u=/-(-?)([a-z])/gi,h=function(t){return t.replace(u,function(t,e,n){return e?e+n:n.toUpperCase()})},l=/([A-Z])/g,f=function(t){return t.replace(l,function(t){return"-"+t.toLowerCase()})},d={noop:function(){},ie:function(){for(var t,e=3,n=s.createElement("div"),i=n.getElementsByTagName("i");n.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->",i[0];);return e>4?e:t}(),isObject:function(t){return"object"==typeof t&&null!==t},isUndefined:function(t){return"undefined"==typeof t},isFunction:function(t){return"function"==typeof t},isArray:function(t){ | ||
return d.ie?t&&t.constructor+""==Array+"":Array.isArray(t)},isNumeric:function(t){return!d.isArray(t)&&t-parseFloat(t)+1>=0},isPlainObject:function(t){return!t||"[object Object]"!=={}.toString.call(t)||t.nodeType||t===t.window?!1:!0},beforeFn:function(t,e,n){return function(){var i=e.apply(this,arguments);return n&&n.call(this,i,arguments)?i:t.apply(this,arguments)}},afterFn:function(t,e,n){return function(){var i=t.apply(this,arguments);return n&&n.call(this,i,arguments)?i:(e.apply(this,arguments),i)}},parseKeyPath:i,deepSet:function(t,e,n){if(t){var s=i(t),a=n;s.forEach(function(t,n){n===s.length-1?a[t]=e:a&&a.hasOwnProperty(t)?a=a[t]:(a[t]={},a=a[t])})}else r(n,e);return n},extend:r,create:c,toArray:function(t){var e=[];try{e=Array.prototype.slice.call(t)}catch(n){for(var i=0,r=t.length;r>i;i++)e[i]=t[i]}return e},hyphenToCamel:h,camelToHyphen:f};e.exports=d},{"./env.js":19}],26:[function(t,e,n){"use strict";function i(t,e){var n,i,r=t,s=[],a=l[e.path];e.watcher=this,this.state=1,this.dir=e,this.vm=t,this.watchers=[],this.val=0/0,e.parse(),a&&a._type===e.type||(a=o.summary(e.ast),a._type=e.type,l[e.path]=a),e.summary=a;for(var c=0,u=e.summary.paths.length;u>c;c++)n=h(t,e.summary.paths[c]),r=n.vm,i=n.path,e.watch?(r._watchers[i]=r._watchers[i]||[],r._watchers[i].push(this),s=r._watchers[i]):s=[this],this.watchers.push(s);e.immediate!==!1&&this.update()}function r(t,e,n){var i;try{i=o.summary(u(e))}catch(r){r.message='SyntaxError in "'+e+'" | '+r.message,console.error(r)}i.paths.forEach(function(e){for(var i,r=t._watchers[e]||[],s=r.length-1;s>=0;s--)i=r[s].dir.update,(i===n||i._originFn===n)&&r[s].unwatch()})}function s(t){return t.path?new i(this,t):void 0}function a(t){var e=this.val;this.val=t,this.dir.update(t,e)}var o=t("./eval.js"),c=t("./utils.js"),u=t("./parse.js").parse,h=t("./scope").reformScope,l={};i.unwatch=r,i.addWatcher=s,i.getWatchers=function(t,e){var n,i=t._watchers,r=[];for(var s in i)n=s.charAt(e.length),0===s.indexOf(e)&&"."===n&&(r=r.concat(i[s]));return r},c.extend(i.prototype,{update:function(){var t,e=this;return this._hide?void(this._needUpdate=!0):(t=this.dir.getValue(this.vm),void((t!==this.val||c.isObject(t))&&(t&&t.then?t.then(function(t){a.call(e,t)}):a.call(this,t))))},unwatch:function(){this.watchers.forEach(function(t){for(var e=t.length-1;e>=0;e--)t[e]===this&&(this.state&&(t[e].dir.unLink(),this.state=0),t.splice(e,1))}.bind(this)),this.watchers=[]}}),e.exports=i},{"./eval.js":20,"./parse.js":22,"./scope":23,"./utils.js":25}]},{},[2])(2)}); | ||
//# sourceMappingURL=bee.min.js.map |
@@ -0,1 +1,5 @@ | ||
0.5.2 | ||
--- | ||
- 复杂类型支持通过组件标签属性方式传递 | ||
0.5.0 | ||
@@ -2,0 +6,0 @@ --- |
{ | ||
"name": "beejs", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "轻量级 MVVM 库", | ||
@@ -14,3 +14,3 @@ "main": "src/bee.js", | ||
"devDependencies": { | ||
"browserify": "^10.0.0", | ||
"browserify": "^11.0.0", | ||
"del": "^1.1.1", | ||
@@ -26,7 +26,7 @@ "es6-promise": "^2.1.1", | ||
"jquery": "^1.11.2", | ||
"jsdom": "^0.10.6", | ||
"tape": "^4.0.0", | ||
"through2": "^0.6.5", | ||
"vinyl-source-stream": "^1.1.0", | ||
"zuul": "^3.0.0", | ||
"jsdom": "^0.10.6" | ||
"zuul": "^3.2.0" | ||
}, | ||
@@ -38,6 +38,5 @@ "browser": { | ||
"transform": [ | ||
"./tools/gulp.versionFix" | ||
"./tools/versionFix" | ||
] | ||
}, | ||
"dependencies": {}, | ||
"directories": { | ||
@@ -44,0 +43,0 @@ "doc": "docs", |
@@ -121,8 +121,11 @@ "use strict"; | ||
//静态属性 | ||
extend(Bee, {extend: utils.afterFn(Class.extend, utils.noop, function(sub) { | ||
//每个构造函数都有自己的 directives ,components, filters 引用 | ||
sub.directives = extend(create(this.directives), sub.directives); | ||
sub.components = extend(create(this.components), sub.components); | ||
sub.filters = extend(create(this.filters), sub.filters); | ||
sub.defaults = extend(true, {}, this.defaults, sub.defaults); | ||
extend(Bee, {extend: utils.afterFn(Class.extend, utils.noop, function(sub, args) { | ||
var staticProps = args[1] || {}; | ||
//每个构造函数都有自己的 directives ,components, filters 引用, 继承自父构造函数 | ||
//默认情况下, 更新父构造函数 directive, components, filters 会同步更新子构造函数. 反之不行 | ||
sub.directives = extend(create(this.directives), staticProps.directives); | ||
sub.components = extend(create(this.components), staticProps.components); | ||
sub.filters = extend(create(this.filters), staticProps.filters); | ||
sub.defaults = extend(true, {}, this.defaults, staticProps.defaults); | ||
}), utils: utils}, Dir, Com, { | ||
@@ -163,3 +166,3 @@ setPrefix: setPrefix | ||
}else{ | ||
instance = new Bee(el, props); | ||
instance = new this(el, props); | ||
} | ||
@@ -270,3 +273,3 @@ return instance | ||
for (var i = 0, l = watchers.length; i < l; i++) { | ||
watchers[i].update(); | ||
watchers[i] && watchers[i].update(); | ||
} | ||
@@ -273,0 +276,0 @@ |
@@ -73,2 +73,5 @@ "use strict"; | ||
}else { | ||
if(this.type == 'attr' && this.escape === false) { | ||
this.path = '{' + this.path + '}' | ||
} | ||
try { | ||
@@ -75,0 +78,0 @@ this.ast = parse(this.path, this.type); |
@@ -19,8 +19,11 @@ "use strict"; | ||
var newAttrs = {}; | ||
var textMap = this.textMap | ||
//b-attr | ||
if(this.dirName === this.type) { | ||
for(var attr in val) { | ||
setAttr(el, attr, val[attr]); | ||
//if(val[attr]) { | ||
delete this.attrs[attr]; | ||
//} | ||
setProperty.call(this, el, attr, val[attr]); | ||
delete this.attrs[attr]; | ||
newAttrs[attr] = true; | ||
@@ -31,3 +34,3 @@ } | ||
for(var attr in this.attrs) { | ||
removeAttr(el, attr); | ||
removeProperty.call(this, el, attr); | ||
} | ||
@@ -37,6 +40,6 @@ this.attrs = newAttrs; | ||
if(this.conditional) { | ||
val ? setAttr(el, this.dirName, val) : removeAttr(el, this.dirName); | ||
val ? setProperty.call(this, el, this.dirName, val) : removeProperty.call(this, el, this.dirName); | ||
}else{ | ||
this.textMap[this.position] = val && (val + ''); | ||
setAttr(el, this.dirName, this.textMap.join('')); | ||
textMap[this.position] = val; | ||
setProperty.call(this, el, this.dirName, textMap.length > 1 ? textMap.join('') : textMap[0]); | ||
} | ||
@@ -47,4 +50,20 @@ } | ||
function setProperty(el, key, val) { | ||
if(isComponent(this)) { | ||
el.bee.$set(utils.hyphenToCamel(key), val) | ||
}else{ | ||
setAttr(el, key, val) | ||
} | ||
} | ||
//IE 浏览器很多属性通过 `setAttribute` 设置后无效. | ||
function removeProperty(el, key, undef) { | ||
if(isComponent(this)) { | ||
el.bee.$set(utils.hyphenToCamel(key), undef) | ||
}else{ | ||
el.removeAttribute(key); | ||
} | ||
} | ||
//IE 浏览器很多属性通过 `setAttribute` 设置后无效. | ||
//这些通过 `el[attr] = value` 设置的属性却能够通过 `removeAttribute` 清除. | ||
@@ -67,4 +86,5 @@ function setAttr(el, attr, val){ | ||
function removeAttr(el, attr) { | ||
el.removeAttribute(attr); | ||
} | ||
function isComponent (dir) { | ||
var component = dir.el.bee; | ||
return component && !component.__repeat && component != dir.vm; | ||
} |
@@ -16,9 +16,10 @@ //component as directive | ||
var cstr = vm.constructor; | ||
var comp, content; | ||
//var refName; | ||
var dirs = [], $data = {}; | ||
var comp; | ||
var dirs, $data = {}; | ||
var Comp = cstr.getComponent(this.path) | ||
var statics = {}; | ||
if(Comp) { | ||
//直接 `Bee.mount` 一个组件 | ||
if(Comp === cstr && vm.__mountcall || el.bee && el.bee === vm) { | ||
@@ -28,8 +29,3 @@ return; | ||
dirs = this.dirs; | ||
dirs = dirs.filter(function (dir) { | ||
// if(dir.type === 'ref') { | ||
// refName = dir.path; | ||
// } | ||
dirs = this.dirs.filter(function (dir) { | ||
return dir.type == 'attr' || dir.type == 'with'; | ||
@@ -44,41 +40,53 @@ }); | ||
//comPath = '$data' | ||
utils.extend($data, vm.$get(curPath)) | ||
utils.extend(true, $data, vm.$get(curPath)) | ||
//监听父组件更新, 同步数据 | ||
//TODO 移到 b-with 指令中完成 | ||
vm.$watch(curPath, function (val) { | ||
comp && comp.$set(utils.extend({}, vm.$get(curPath))); | ||
}) | ||
}else{ | ||
comPath = utils.hyphenToCamel(dir.dirName); | ||
$data[comPath] = vm.$get(curPath); | ||
$data[comPath] = getProperty(dir) | ||
dir.el.removeAttribute(dir.dirName) | ||
} | ||
//监听父组件更新, 同步数据 | ||
vm.$watch(curPath, function (val) { | ||
if(comp){ | ||
val = dir.textMap ? dir.textMap.join('') : val; | ||
comPath ? comp.$set(comPath, val) : comp.$set(val); | ||
} | ||
}) | ||
}); | ||
//content = domUtils.createContent(el.childNodes); | ||
//组件内容属于其容器 | ||
vm.__links = vm.__links.concat(checkBinding.walk.call(vm, el.childNodes)); | ||
//el.appendChild(content) | ||
statics = domUtils.getAttrs(el) | ||
//排除指令属性 | ||
var _dir; | ||
for(var attr in statics) { | ||
_dir = utils.camelToHyphen(attr); | ||
_dir = _dir.slice(vm.constructor.prefix.length) | ||
if(_dir in vm.constructor.directives) { | ||
delete statics[attr] | ||
} | ||
} | ||
this.component = comp = new Comp({ | ||
$el: el, | ||
$isReplace: true, | ||
$data: utils.extend({}, Comp.prototype.$data, $data, domUtils.getAttrs(el)) | ||
$data: utils.extend(true, {}, $data, statics) | ||
}); | ||
el.bee = comp; | ||
//直接将component 作为根元素时, 同步跟新容器 .$el 引用 | ||
// if(vm.$el === el) { | ||
// vm.__ref = comp; | ||
// vm.$el = comp.$el; | ||
// } | ||
return comp; | ||
}else{ | ||
console.warn('Component: ' + this.path + ' not defined! Ignore'); | ||
console.error('Component: ' + this.path + ' not defined!'); | ||
} | ||
} | ||
}; | ||
//如果组件的属性只有一个表达式, 则保持该表达式的数据类型 | ||
function getProperty(dir) { | ||
var textMap = dir.textMap, val | ||
val = textMap && textMap.length > 1 ? textMap.join('') : textMap[0] | ||
return utils.isPlainObject(val) ? utils.extend(true, {}, val) : val; | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
, events = require('../event-bind.js') | ||
, checkBinding = require('../check-binding') | ||
; | ||
@@ -68,2 +69,5 @@ | ||
}else{ | ||
//优先解析内部内容 | ||
vm.__links = vm.__links.concat(checkBinding.walk.call(vm, comp.childNodes)); | ||
//HTML 原生控件的双向绑定 | ||
@@ -70,0 +74,0 @@ switch(comp.tagName) { |
@@ -21,13 +21,10 @@ "use strict"; | ||
, link: function() { | ||
var cstr = this.cstr = this.vm.constructor; | ||
var Bee = require('../bee') | ||
while(cstr.__super__){ | ||
cstr = cstr.__super__.constructor; | ||
} | ||
this.trackId = this.el.getAttribute('track-by') | ||
this.el.removeAttribute('track-by') | ||
//只继承静态的默认参数 | ||
this.cstr = cstr.extend({}, this.cstr) | ||
//创建 repeat 的匿名构造函数 | ||
//继承父构造函数的 `directives, components, filters` 属性 | ||
this.cstr = Bee.extend({}, this.vm.constructor) | ||
@@ -54,2 +51,5 @@ //默认数据不应继承 | ||
//TODO 将数组修饰移至所有表达式中 | ||
var arrs = []; //repeat 表达式中出现的数组 | ||
if(utils.isArray(items)) { | ||
@@ -133,37 +133,40 @@ // 在 repeat 指令表达式中相关变量 | ||
this.summary.paths.forEach(function(localKey) { | ||
var local = that.vm.$get(localKey); | ||
this.listPath.forEach(function(localKey) { | ||
var local = that.vm.$get(localKey) | ||
utils.isArray(local) && arrs.push(local) | ||
}) | ||
arrs.push(items) | ||
arrs.forEach(function(local) { | ||
var dirs = local.__dirs__; | ||
if(utils.isArray(local)) { | ||
if(!dirs){ | ||
//数组操作方法 | ||
utils.extend(local, { | ||
$set: function(i, item) { | ||
local.splice(i, 1, utils.isObject(item) ? utils.extend({}, local[i], item) : item) | ||
}, | ||
$replace: function(i, item) { | ||
local.splice(i, 1, item) | ||
}, | ||
$remove: function(i) { | ||
local.splice(i, 1); | ||
} | ||
}); | ||
arrayMethods.forEach(function(method) { | ||
local[method] = utils.afterFn(local[method], function() { | ||
dirs.forEach(function(dir) { | ||
dir.listPath.forEach(function(path) { | ||
var reformed = scope.reformScope(dir.vm, path) | ||
reformed.vm.$update(reformed.path) | ||
}) | ||
if(!dirs){ | ||
//数组操作方法 | ||
utils.extend(local, { | ||
$set: function(i, item) { | ||
local.splice(i, 1, utils.isObject(item) ? utils.extend({}, local[i], item) : item) | ||
}, | ||
$replace: function(i, item) { | ||
local.splice(i, 1, item) | ||
}, | ||
$remove: function(i) { | ||
local.splice(i, 1); | ||
} | ||
}); | ||
arrayMethods.forEach(function(method) { | ||
local[method] = utils.afterFn(local[method], function() { | ||
dirs.forEach(function(dir) { | ||
dir.listPath.forEach(function(path) { | ||
var reformed = scope.reformScope(dir.vm, path) | ||
reformed.vm.$update(reformed.path) | ||
}) | ||
}) | ||
}); | ||
dirs = local.__dirs__ = []; | ||
} | ||
//一个数组多处使用 | ||
//TODO 移除时的情况 | ||
if(dirs.indexOf(that) === -1) { | ||
dirs.push(that) | ||
} | ||
}) | ||
}); | ||
dirs = local.__dirs__ = []; | ||
} | ||
//一个数组多处使用 | ||
//TODO 移除时的情况 | ||
if(dirs.indexOf(that) === -1) { | ||
dirs.push(that) | ||
} | ||
}) | ||
@@ -170,0 +173,0 @@ |
@@ -5,3 +5,2 @@ "use strict"; | ||
var utils = require('../utils') | ||
var camelReg = /([A-Z])/g; | ||
@@ -34,5 +33,3 @@ //默认单位为 px 的属性 | ||
//marginTop -> margin-top. 驼峰转连接符式 | ||
dashKey = key.replace(camelReg, function (upperChar) { | ||
return '-' + upperChar.toLowerCase(); | ||
}); | ||
dashKey = utils.camelToHyphen(key); | ||
@@ -39,0 +36,0 @@ if (pixelAttrs.indexOf(dashKey) >= 0 && utils.isNumeric(val)) { |
@@ -46,3 +46,5 @@ /** | ||
, '.': function(l, r) { | ||
if(r && path){ | ||
var prev = this.first; | ||
//排除 a[b].c 这种情况 | ||
if(r && path && !(prev.arity === 'binary' && prev.value === '[')){ | ||
path = path + '.' + r; | ||
@@ -163,3 +165,2 @@ } | ||
case 'name': | ||
summary.locals[value] = true; | ||
res = getValue(value, context.locals); | ||
@@ -172,3 +173,3 @@ break; | ||
case 'this': | ||
res = context.locals;//TODO this 指向 vm 还是 dir? | ||
res = context.locals; | ||
break; | ||
@@ -196,3 +197,3 @@ } | ||
summary = {filters: {}, locals: {}, paths: {}, assignments: {}}; | ||
summary = {filters: {}, paths: {}, assignments: {}}; | ||
path = ''; | ||
@@ -217,3 +218,3 @@ } | ||
//表达式摘要 | ||
//return: {filters:[], locals:[], paths: [], assignments: []} | ||
//return: {filters:[], paths: [], assignments: []} | ||
exports.summary = function(tree) { | ||
@@ -220,0 +221,0 @@ reset(); |
@@ -1,2 +0,2 @@ | ||
var tokenReg = /{{({([^}\n]+)}|[^}\n]+)}}/g; | ||
var tokenReg = /{{({(.+?)}|.+?)}}/g; | ||
@@ -15,5 +15,5 @@ //字符串中是否包含模板占位符标记 | ||
; | ||
tokenReg.lastIndex = 0; | ||
while((val = tokenReg.exec(value))){ | ||
@@ -23,3 +23,3 @@ if(tokenReg.lastIndex - start > val[0].length){ | ||
} | ||
token = { | ||
@@ -31,17 +31,17 @@ escape: !val[2] | ||
}; | ||
tokens.push(token); | ||
//一个引用类型(数组)作为节点对象的文本图, 这样当某一个引用改变了一个值后, 其他引用取得的值都会同时更新 | ||
textMap.push(val[0]); | ||
start = tokenReg.lastIndex; | ||
} | ||
if(value.length > start){ | ||
textMap.push(value.slice(start, value.length)); | ||
} | ||
tokens.textMap = textMap; | ||
return tokens; | ||
@@ -52,2 +52,2 @@ } | ||
exports.parseToken = parseToken; | ||
exports.parseToken = parseToken; |
@@ -125,6 +125,27 @@ "use strict"; | ||
//驼峰转连接符 | ||
var camelReg = /([A-Z])/g; | ||
var camelToHyphen = function(key) { | ||
return key.replace(camelReg, function (upperChar) { | ||
return '-' + upperChar.toLowerCase(); | ||
}) | ||
} | ||
var utils = { | ||
noop: function (){} | ||
, ie: !!doc.attachEvent | ||
, ie: (function(){ | ||
var undef, | ||
v = 3, | ||
div = doc.createElement('div'), | ||
all = div.getElementsByTagName('i'); | ||
while ( | ||
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', | ||
all[0] | ||
); | ||
return v > 4 ? v : undef; | ||
}()) | ||
, isObject: function (val) { | ||
@@ -167,3 +188,3 @@ return typeof val === 'object' && val !== null; | ||
var ret = fn.apply(this, arguments); | ||
if(breakCheck && breakCheck.call(this, ret)){ | ||
if(breakCheck && breakCheck.call(this, ret, arguments)){ | ||
return ret; | ||
@@ -178,3 +199,3 @@ } | ||
var ret = oriFn.apply(this, arguments); | ||
if(breakCheck && breakCheck.call(this, ret)){ | ||
if(breakCheck && breakCheck.call(this, ret, arguments)){ | ||
return ret; | ||
@@ -225,6 +246,7 @@ } | ||
return arr; | ||
}, | ||
hyphenToCamel: hyphenToCamel | ||
} | ||
, hyphenToCamel: hyphenToCamel | ||
, camelToHyphen: camelToHyphen | ||
}; | ||
module.exports = utils; |
var test = require('tape'); | ||
var Bee = require('../../'); | ||
var utils = require('../../src/utils') | ||
var $ = require('jquery') | ||
@@ -12,8 +14,8 @@ if(typeof window === 'undefined') { | ||
Bee.tag('ant', Ant) | ||
test('静态内容', function(t) { | ||
Bee.tag('ant', Ant) | ||
var bee = new Bee({ | ||
$tpl: '<div class="container"><ant><span>这里是</span><span>$content的内容</span></ant></div>' | ||
$tpl: '<div class="container"><div b-tag="ant"><span>这里是</span><span>$content的内容</span></div></div>' | ||
}) | ||
@@ -24,3 +26,3 @@ | ||
t.ok($el.hasClass('container')) | ||
t.ok($el.children().hasClass('component')) | ||
t.ok($el.children().hasClass('component'), '组件内容默认会替换自定义标签') | ||
@@ -35,4 +37,6 @@ t.equal($el.children().children().length, 2) | ||
Bee.tag('ant', Ant) | ||
var bee = new Bee({ | ||
$tpl: '<div class="container"><ant><span>{{text}}</span><span>here</span></ant></div>', | ||
$tpl: '<div class="container"><div b-tag="ant"><span>{{text}}</span><span>here</span></div></div>', | ||
$data: {text: 'container content '} | ||
@@ -55,4 +59,6 @@ }) | ||
Bee.tag('ant', Ant) | ||
var bee = new Bee({ | ||
$tpl: '<div class="container"><ant><span b-if="flag">{{text}}</span><span>here</span></ant></div>', | ||
$tpl: '<div class="container"><div b-tag="ant"><span b-if="flag">{{text}}</span><span>here</span></div></div>', | ||
$data: {text: 'container content '} | ||
@@ -81,4 +87,6 @@ }) | ||
Bee.tag('ant', Ant) | ||
var bee = new Bee({ | ||
$tpl: '<div class="container"><ant><span b-repeat="item in list">{{item}} </span><span>here</span></ant></div>', | ||
$tpl: '<div class="container"><div b-tag="ant"><span b-repeat="item in list">{{item}} </span><span>here</span></div></div>', | ||
$data: {list: ['ant']} | ||
@@ -85,0 +93,0 @@ }) |
@@ -47,6 +47,6 @@ var test = require('tape'); | ||
var Test = Bee.tag('test', { | ||
$tpl: '<div>test</div>' | ||
$tpl: '<div>test{{a}}</div>' | ||
}) | ||
var tpl = '<div><span b-component="test" b-if="flag"></span></div>' | ||
var tpl = '<div><span b-component="test" b-if="flag" a="{{ a }}"></span></div>' | ||
var bee = new Bee(tpl) | ||
@@ -60,3 +60,13 @@ | ||
bee.$set('flag', false) | ||
bee.$set('a', ' aa') | ||
t.equal($(bee.$el).text(), '') | ||
bee.$set('flag', true) | ||
t.equal($(bee.$el).text(), 'test aa') | ||
t.end() | ||
}) |
require("es6-promise").polyfill(); | ||
require('./directives/test.class.js'); | ||
require('./directives/test.component.js'); | ||
require('./directives/test.content.js'); | ||
require('./directives/test.if.js'); | ||
@@ -3,0 +6,0 @@ require('./directives/test.ref.js'); |
@@ -61,3 +61,5 @@ var test = require('tape'); | ||
t.test('Bee.extend', function(t) { | ||
var proto = {pro: Math.random()}, staticProp = {sta: Math.random(), filters: {b: function(){}}}; | ||
var proto = {pro: Math.random()}, | ||
staticProp = {sta: Math.random(), filters: {b: function(){}}}; | ||
var Ant = Bee.extend(proto, staticProp) | ||
@@ -69,3 +71,3 @@ t.equal(Ant.sta, staticProp.sta); | ||
t.equal(Ant.directive, Bee.directive); | ||
t.ok(Ant.filters.b) | ||
t.equal(Ant.filters.b, staticProp.filters.b) | ||
@@ -84,2 +86,20 @@ t.notOk(Bee.sta) | ||
t.comment('更新父构造函数 directive, components, filters 会同步更新子构造函数') | ||
var newFilter = function() {} | ||
Ant.filter('b', newFilter) | ||
t.equal(Ant.filters.b, newFilter, 'filter update') | ||
t.equal(Cicada.filters.b, newFilter, 'filter update') | ||
t.notEqual(newFilter, staticProp.filters.b) | ||
t.comment('反之不行') | ||
Cicada.filter('b', staticProp.filters.b) | ||
t.equal(Cicada.filters.b, staticProp.filters.b, 'filter update') | ||
t.equal(Ant.filters.b, newFilter, 'filter update') | ||
t.notEqual(newFilter, staticProp.filters.b) | ||
t.end() | ||
@@ -86,0 +106,0 @@ }) |
@@ -29,3 +29,23 @@ var test = require('tape'); | ||
t.test('sub class mount', function(t) { | ||
var Ant = Bee.extend() | ||
Ant.tag('test2', {}) | ||
var tpl = '<div><test2 b-ref="test" attr="1"></test2></div>' | ||
var bee = Bee.mount($(tpl)[0]) | ||
t.notOk(bee.$refs.test.$data) | ||
bee = Ant.mount($(tpl)[0]) | ||
t.ok(bee.$refs.test.$data) | ||
t.equal(bee.$refs.test.$data.attr, "1") | ||
t.end() | ||
}) | ||
t.end() | ||
}) |
@@ -75,3 +75,3 @@ var test = require('tape'); | ||
t.test('parse: a + b', function(t) { | ||
var l = summary(parse('a + b')).locals; | ||
var l = summary(parse('a + b')).paths; | ||
@@ -87,8 +87,4 @@ t.equal(l.length, 2); | ||
var s = summary(parse('a.abc')) | ||
, l = s.locals | ||
; | ||
t.equal(l.length, 1); | ||
t.equal(l[0], 'a'); | ||
t.equal(s.paths.length, 1); | ||
@@ -102,9 +98,5 @@ t.equal(s.paths[0], 'a.abc'); | ||
var s = summary(parse('a[abc]')) | ||
, l = s.locals | ||
, l = s.paths | ||
; | ||
t.equal(l.length, 2); | ||
t.equal(l[0], 'a'); | ||
t.equal(l[1], 'abc'); | ||
t.equal(s.paths.length, 2); | ||
@@ -119,8 +111,4 @@ t.equal(s.paths[0], 'a'); | ||
var s = summary(parse('a["abc"]')) | ||
, l = s.locals | ||
; | ||
t.equal(l.length, 1); | ||
t.equal(l[0], 'a'); | ||
t.equal(s.paths.length, 1); | ||
@@ -131,2 +119,27 @@ t.equal(s.paths[0], 'a.abc'); | ||
}); | ||
t.test('parse: a[abc]', function(t) { | ||
var s = summary(parse('a[abc]')) | ||
, l = s.paths | ||
; | ||
t.equal(s.paths.length, 2); | ||
t.equal(s.paths[0], 'a'); | ||
t.equal(s.paths[1], 'abc'); | ||
t.end(); | ||
}); | ||
//动态 paths | ||
t.test('parse: a[abc].b', function(t) { | ||
var s = summary(parse('a[abc].b')) | ||
, l = s.paths | ||
; | ||
t.equal(s.paths.length, 2); | ||
t.equal(s.paths[0], 'a'); | ||
t.equal(s.paths[1], 'abc'); | ||
t.end(); | ||
}); | ||
}); | ||
@@ -199,4 +212,3 @@ | ||
var context = { | ||
locals: {a: 1, b: 1, c:1} | ||
, filters: {filter: 1, fi: 1} | ||
filters: {filter: 1, fi: 1} | ||
, paths: {'a.b': 1, 'b.c': 1, b: 1, 'a.bc': 1, 'c.0': 1} | ||
@@ -214,3 +226,2 @@ }; | ||
t.equal(Object.keys(context.locals).length, 0, 'lcoals'); | ||
t.equal(Object.keys(context.filters).length, 0, 'filters'); | ||
@@ -225,3 +236,2 @@ t.equal(Object.keys(context.paths).length, 0, 'paths'); | ||
t.equal(s.locals.length, 0, 'locals'); | ||
t.equal(s.filters.length, 0, 'filters'); | ||
@@ -228,0 +238,0 @@ t.equal(s.paths.length, 0, 'paths'); |
- [ ] 同步数组多实例时, 内部的更新的同步问题 | ||
- [ ] 通过 HTML 属性传递复杂类型数据 | ||
- [ ] `track-by="$index"` 支持 | ||
- [x] 通过 HTML 属性传递复杂类型数据 | ||
- [ ] transition | ||
- [ ] 移除 node 端的 jsdom 依赖 | ||
- [ ] 文档, 文档, 测试, 测试 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
670224
74
9419