a-template
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -8,3 +8,3 @@ /** | ||
* author: steelydylan | ||
* version: 0.5.1 | ||
* version: 0.5.2 | ||
* | ||
@@ -88,2 +88,2 @@ * array.prototype.find: | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.aTemplate=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var ES=require("es-abstract/es6");module.exports=function find(predicate){var list=ES.ToObject(this);var length=ES.ToInteger(ES.ToLength(list.length));if(!ES.IsCallable(predicate)){throw new TypeError("Array#find: predicate must be a function")}if(length===0){return undefined}var thisArg=arguments[1];for(var i=0,value;i<length;i++){value=list[i];if(ES.Call(predicate,thisArg,[value,i,list])){return value}}return undefined}},{"es-abstract/es6":7}],2:[function(require,module,exports){"use strict";var define=require("define-properties");var ES=require("es-abstract/es6");var implementation=require("./implementation");var getPolyfill=require("./polyfill");var shim=require("./shim");var slice=Array.prototype.slice;var polyfill=getPolyfill();var boundFindShim=function find(array,predicate){ES.RequireObjectCoercible(array);var args=slice.call(arguments,1);return polyfill.apply(array,args)};define(boundFindShim,{getPolyfill:getPolyfill,implementation:implementation,shim:shim});module.exports=boundFindShim},{"./implementation":1,"./polyfill":3,"./shim":4,"define-properties":5,"es-abstract/es6":7}],3:[function(require,module,exports){"use strict";module.exports=function getPolyfill(){var implemented=Array.prototype.find&&[,1].find(function(){return true})!==1;return implemented?Array.prototype.find:require("./implementation")}},{"./implementation":1}],4:[function(require,module,exports){"use strict";var define=require("define-properties");var getPolyfill=require("./polyfill");module.exports=function shimArrayPrototypeFind(){var polyfill=getPolyfill();define(Array.prototype,{find:polyfill},{find:function(){return Array.prototype.find!==polyfill}});return polyfill}},{"./polyfill":3,"define-properties":5}],5:[function(require,module,exports){"use strict";var keys=require("object-keys");var foreach=require("foreach");var hasSymbols=typeof Symbol==="function"&&typeof Symbol()==="symbol";var toStr=Object.prototype.toString;var isFunction=function(fn){return typeof fn==="function"&&toStr.call(fn)==="[object Function]"};var arePropertyDescriptorsSupported=function(){var obj={};try{Object.defineProperty(obj,"x",{enumerable:false,value:obj});for(var _ in obj){return false}return obj.x===obj}catch(e){return false}};var supportsDescriptors=Object.defineProperty&&arePropertyDescriptorsSupported();var defineProperty=function(object,name,value,predicate){if(name in object&&(!isFunction(predicate)||!predicate())){return}if(supportsDescriptors){Object.defineProperty(object,name,{configurable:true,enumerable:false,value:value,writable:true})}else{object[name]=value}};var defineProperties=function(object,map){var predicates=arguments.length>2?arguments[2]:{};var props=keys(map);if(hasSymbols){props=props.concat(Object.getOwnPropertySymbols(map))}foreach(props,function(name){defineProperty(object,name,map[name],predicates[name])})};defineProperties.supportsDescriptors=!!supportsDescriptors;module.exports=defineProperties},{foreach:17,"object-keys":26}],6:[function(require,module,exports){"use strict";var $isNaN=require("./helpers/isNaN");var $isFinite=require("./helpers/isFinite");var sign=require("./helpers/sign");var mod=require("./helpers/mod");var IsCallable=require("is-callable");var toPrimitive=require("es-to-primitive/es5");var ES5={ToPrimitive:toPrimitive,ToBoolean:function ToBoolean(value){return Boolean(value)},ToNumber:function ToNumber(value){return Number(value)},ToInteger:function ToInteger(value){var number=this.ToNumber(value);if($isNaN(number)){return 0}if(number===0||!$isFinite(number)){return number}return sign(number)*Math.floor(Math.abs(number))},ToInt32:function ToInt32(x){return this.ToNumber(x)>>0},ToUint32:function ToUint32(x){return this.ToNumber(x)>>>0},ToUint16:function ToUint16(value){var number=this.ToNumber(value);if($isNaN(number)||number===0||!$isFinite(number)){return 0}var posInt=sign(number)*Math.floor(Math.abs(number));return mod(posInt,65536)},ToString:function ToString(value){return String(value)},ToObject:function ToObject(value){this.CheckObjectCoercible(value);return Object(value)},CheckObjectCoercible:function CheckObjectCoercible(value,optMessage){if(value==null){throw new TypeError(optMessage||"Cannot call method on "+value)}return value},IsCallable:IsCallable,SameValue:function SameValue(x,y){if(x===y){if(x===0){return 1/x===1/y}return true}return $isNaN(x)&&$isNaN(y)},Type:function Type(x){if(x===null){return"Null"}if(typeof x==="undefined"){return"Undefined"}if(typeof x==="function"||typeof x==="object"){return"Object"}if(typeof x==="number"){return"Number"}if(typeof x==="boolean"){return"Boolean"}if(typeof x==="string"){return"String"}}};module.exports=ES5},{"./helpers/isFinite":9,"./helpers/isNaN":10,"./helpers/mod":12,"./helpers/sign":13,"es-to-primitive/es5":14,"is-callable":21}],7:[function(require,module,exports){"use strict";var toStr=Object.prototype.toString;var hasSymbols=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol";var symbolToStr=hasSymbols?Symbol.prototype.toString:toStr;var $isNaN=require("./helpers/isNaN");var $isFinite=require("./helpers/isFinite");var MAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1;var assign=require("./helpers/assign");var sign=require("./helpers/sign");var mod=require("./helpers/mod");var isPrimitive=require("./helpers/isPrimitive");var toPrimitive=require("es-to-primitive/es6");var parseInteger=parseInt;var bind=require("function-bind");var strSlice=bind.call(Function.call,String.prototype.slice);var isBinary=bind.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i);var isOctal=bind.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i);var nonWS=[" ","",""].join("");var nonWSregex=new RegExp("["+nonWS+"]","g");var hasNonWS=bind.call(Function.call,RegExp.prototype.test,nonWSregex);var invalidHexLiteral=/^[-+]0x[0-9a-f]+$/i;var isInvalidHexLiteral=bind.call(Function.call,RegExp.prototype.test,invalidHexLiteral);var ws=[" \n\f\r "," \u2028","\u2029\ufeff"].join("");var trimRegex=new RegExp("(^["+ws+"]+)|(["+ws+"]+$)","g");var replace=bind.call(Function.call,String.prototype.replace);var trim=function(value){return replace(value,trimRegex,"")};var ES5=require("./es5");var hasRegExpMatcher=require("is-regex");var ES6=assign(assign({},ES5),{Call:function Call(F,V){var args=arguments.length>2?arguments[2]:[];if(!this.IsCallable(F)){throw new TypeError(F+" is not a function")}return F.apply(V,args)},ToPrimitive:toPrimitive,ToNumber:function ToNumber(argument){var value=isPrimitive(argument)?argument:toPrimitive(argument,"number");if(typeof value==="symbol"){throw new TypeError("Cannot convert a Symbol value to a number")}if(typeof value==="string"){if(isBinary(value)){return this.ToNumber(parseInteger(strSlice(value,2),2))}else if(isOctal(value)){return this.ToNumber(parseInteger(strSlice(value,2),8))}else if(hasNonWS(value)||isInvalidHexLiteral(value)){return NaN}else{var trimmed=trim(value);if(trimmed!==value){return this.ToNumber(trimmed)}}}return Number(value)},ToInt16:function ToInt16(argument){var int16bit=this.ToUint16(argument);return int16bit>=32768?int16bit-65536:int16bit},ToInt8:function ToInt8(argument){var int8bit=this.ToUint8(argument);return int8bit>=128?int8bit-256:int8bit},ToUint8:function ToUint8(argument){var number=this.ToNumber(argument);if($isNaN(number)||number===0||!$isFinite(number)){return 0}var posInt=sign(number)*Math.floor(Math.abs(number));return mod(posInt,256)},ToUint8Clamp:function ToUint8Clamp(argument){var number=this.ToNumber(argument);if($isNaN(number)||number<=0){return 0}if(number>=255){return 255}var f=Math.floor(argument);if(f+.5<number){return f+1}if(number<f+.5){return f}if(f%2!==0){return f+1}return f},ToString:function ToString(argument){if(typeof argument==="symbol"){throw new TypeError("Cannot convert a Symbol value to a string")}return String(argument)},ToObject:function ToObject(value){this.RequireObjectCoercible(value);return Object(value)},ToPropertyKey:function ToPropertyKey(argument){var key=this.ToPrimitive(argument,String);return typeof key==="symbol"?symbolToStr.call(key):this.ToString(key)},ToLength:function ToLength(argument){var len=this.ToInteger(argument);if(len<=0){return 0}if(len>MAX_SAFE_INTEGER){return MAX_SAFE_INTEGER}return len},CanonicalNumericIndexString:function CanonicalNumericIndexString(argument){if(toStr.call(argument)!=="[object String]"){throw new TypeError("must be a string")}if(argument==="-0"){return-0}var n=this.ToNumber(argument);if(this.SameValue(this.ToString(n),argument)){return n}return void 0},RequireObjectCoercible:ES5.CheckObjectCoercible,IsArray:Array.isArray||function IsArray(argument){return toStr.call(argument)==="[object Array]"},IsConstructor:function IsConstructor(argument){return typeof argument==="function"&&!!argument.prototype},IsExtensible:function IsExtensible(obj){if(!Object.preventExtensions){return true}if(isPrimitive(obj)){return false}return Object.isExtensible(obj)},IsInteger:function IsInteger(argument){if(typeof argument!=="number"||$isNaN(argument)||!$isFinite(argument)){return false}var abs=Math.abs(argument);return Math.floor(abs)===abs},IsPropertyKey:function IsPropertyKey(argument){return typeof argument==="string"||typeof argument==="symbol"},IsRegExp:function IsRegExp(argument){if(!argument||typeof argument!=="object"){return false}if(hasSymbols){var isRegExp=argument[Symbol.match];if(typeof isRegExp!=="undefined"){return ES5.ToBoolean(isRegExp)}}return hasRegExpMatcher(argument)},SameValueZero:function SameValueZero(x,y){return x===y||$isNaN(x)&&$isNaN(y)},GetV:function GetV(V,P){if(!this.IsPropertyKey(P)){throw new TypeError("Assertion failed: IsPropertyKey(P) is not true")}var O=this.ToObject(V);return O[P]},GetMethod:function GetMethod(O,P){if(!this.IsPropertyKey(P)){throw new TypeError("Assertion failed: IsPropertyKey(P) is not true")}var func=this.GetV(O,P);if(func==null){return undefined}if(!this.IsCallable(func)){throw new TypeError(P+"is not a function")}return func},Get:function Get(O,P){if(this.Type(O)!=="Object"){throw new TypeError("Assertion failed: Type(O) is not Object")}if(!this.IsPropertyKey(P)){throw new TypeError("Assertion failed: IsPropertyKey(P) is not true")}return O[P]},Type:function Type(x){if(typeof x==="symbol"){return"Symbol"}return ES5.Type(x)},SpeciesConstructor:function SpeciesConstructor(O,defaultConstructor){if(this.Type(O)!=="Object"){throw new TypeError("Assertion failed: Type(O) is not Object")}var C=O.constructor;if(typeof C==="undefined"){return defaultConstructor}if(this.Type(C)!=="Object"){throw new TypeError("O.constructor is not an Object")}var S=hasSymbols&&Symbol.species?C[Symbol.species]:undefined;if(S==null){return defaultConstructor}if(this.IsConstructor(S)){return S}throw new TypeError("no constructor found")}});delete ES6.CheckObjectCoercible;module.exports=ES6},{"./es5":6,"./helpers/assign":8,"./helpers/isFinite":9,"./helpers/isNaN":10,"./helpers/isPrimitive":11,"./helpers/mod":12,"./helpers/sign":13,"es-to-primitive/es6":15,"function-bind":19,"is-regex":23}],8:[function(require,module,exports){var has=Object.prototype.hasOwnProperty;module.exports=Object.assign||function assign(target,source){for(var key in source){if(has.call(source,key)){target[key]=source[key]}}return target}},{}],9:[function(require,module,exports){var $isNaN=Number.isNaN||function(a){return a!==a};module.exports=Number.isFinite||function(x){return typeof x==="number"&&!$isNaN(x)&&x!==Infinity&&x!==-Infinity}},{}],10:[function(require,module,exports){module.exports=Number.isNaN||function isNaN(a){return a!==a}},{}],11:[function(require,module,exports){module.exports=function isPrimitive(value){return value===null||typeof value!=="function"&&typeof value!=="object"}},{}],12:[function(require,module,exports){module.exports=function mod(number,modulo){var remain=number%modulo;return Math.floor(remain>=0?remain:remain+modulo)}},{}],13:[function(require,module,exports){module.exports=function sign(number){return number>=0?1:-1}},{}],14:[function(require,module,exports){"use strict";var toStr=Object.prototype.toString;var isPrimitive=require("./helpers/isPrimitive");var isCallable=require("is-callable");var ES5internalSlots={"[[DefaultValue]]":function(O,hint){var actualHint=hint||(toStr.call(O)==="[object Date]"?String:Number);if(actualHint===String||actualHint===Number){var methods=actualHint===String?["toString","valueOf"]:["valueOf","toString"];var value,i;for(i=0;i<methods.length;++i){if(isCallable(O[methods[i]])){value=O[methods[i]]();if(isPrimitive(value)){return value}}}throw new TypeError("No default value")}throw new TypeError("invalid [[DefaultValue]] hint supplied")}};module.exports=function ToPrimitive(input,PreferredType){if(isPrimitive(input)){return input}return ES5internalSlots["[[DefaultValue]]"](input,PreferredType)}},{"./helpers/isPrimitive":16,"is-callable":21}],15:[function(require,module,exports){"use strict";var hasSymbols=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol";var isPrimitive=require("./helpers/isPrimitive");var isCallable=require("is-callable");var isDate=require("is-date-object");var isSymbol=require("is-symbol");var ordinaryToPrimitive=function OrdinaryToPrimitive(O,hint){if(typeof O==="undefined"||O===null){throw new TypeError("Cannot call method on "+O)}if(typeof hint!=="string"||hint!=="number"&&hint!=="string"){throw new TypeError('hint must be "string" or "number"')}var methodNames=hint==="string"?["toString","valueOf"]:["valueOf","toString"];var method,result,i;for(i=0;i<methodNames.length;++i){method=O[methodNames[i]];if(isCallable(method)){result=method.call(O);if(isPrimitive(result)){return result}}}throw new TypeError("No default value")};var GetMethod=function GetMethod(O,P){var func=O[P];if(func!==null&&typeof func!=="undefined"){if(!isCallable(func)){throw new TypeError(func+" returned for property "+P+" of object "+O+" is not a function")}return func}};module.exports=function ToPrimitive(input,PreferredType){if(isPrimitive(input)){return input}var hint="default";if(arguments.length>1){if(PreferredType===String){hint="string"}else if(PreferredType===Number){hint="number"}}var exoticToPrim;if(hasSymbols){if(Symbol.toPrimitive){exoticToPrim=GetMethod(input,Symbol.toPrimitive)}else if(isSymbol(input)){exoticToPrim=Symbol.prototype.valueOf}}if(typeof exoticToPrim!=="undefined"){var result=exoticToPrim.call(input,hint);if(isPrimitive(result)){return result}throw new TypeError("unable to convert exotic object to primitive")}if(hint==="default"&&(isDate(input)||isSymbol(input))){hint="string"}return ordinaryToPrimitive(input,hint==="default"?"number":hint)}},{"./helpers/isPrimitive":16,"is-callable":21,"is-date-object":22,"is-symbol":24}],16:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{dup:11}],17:[function(require,module,exports){var hasOwn=Object.prototype.hasOwnProperty;var toString=Object.prototype.toString;module.exports=function forEach(obj,fn,ctx){if(toString.call(fn)!=="[object Function]"){throw new TypeError("iterator must be a function")}var l=obj.length;if(l===+l){for(var i=0;i<l;i++){fn.call(ctx,obj[i],i,obj)}}else{for(var k in obj){if(hasOwn.call(obj,k)){fn.call(ctx,obj[k],k,obj)}}}}},{}],18:[function(require,module,exports){var ERROR_MESSAGE="Function.prototype.bind called on incompatible ";var slice=Array.prototype.slice;var toStr=Object.prototype.toString;var funcType="[object Function]";module.exports=function bind(that){var target=this;if(typeof target!=="function"||toStr.call(target)!==funcType){throw new TypeError(ERROR_MESSAGE+target)}var args=slice.call(arguments,1);var bound;var binder=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));if(Object(result)===result){return result}return this}else{return target.apply(that,args.concat(slice.call(arguments)))}};var boundLength=Math.max(0,target.length-args.length);var boundArgs=[];for(var i=0;i<boundLength;i++){boundArgs.push("$"+i)}bound=Function("binder","return function ("+boundArgs.join(",")+"){ return binder.apply(this,arguments); }")(binder);if(target.prototype){var Empty=function Empty(){};Empty.prototype=target.prototype;bound.prototype=new Empty;Empty.prototype=null}return bound}},{}],19:[function(require,module,exports){var implementation=require("./implementation");module.exports=Function.prototype.bind||implementation},{"./implementation":18}],20:[function(require,module,exports){var bind=require("function-bind");module.exports=bind.call(Function.call,Object.prototype.hasOwnProperty)},{"function-bind":19}],21:[function(require,module,exports){"use strict";var fnToStr=Function.prototype.toString;var constructorRegex=/^\s*class /;var isES6ClassFn=function isES6ClassFn(value){try{var fnStr=fnToStr.call(value);var singleStripped=fnStr.replace(/\/\/.*\n/g,"");var multiStripped=singleStripped.replace(/\/\*[.\s\S]*\*\//g,"");var spaceStripped=multiStripped.replace(/\n/gm," ").replace(/ {2}/g," ");return constructorRegex.test(spaceStripped)}catch(e){return false}};var tryFunctionObject=function tryFunctionObject(value){try{if(isES6ClassFn(value)){return false}fnToStr.call(value);return true}catch(e){return false}};var toStr=Object.prototype.toString;var fnClass="[object Function]";var genClass="[object GeneratorFunction]";var hasToStringTag=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";module.exports=function isCallable(value){if(!value){return false}if(typeof value!=="function"&&typeof value!=="object"){return false}if(hasToStringTag){return tryFunctionObject(value)}if(isES6ClassFn(value)){return false}var strClass=toStr.call(value);return strClass===fnClass||strClass===genClass}},{}],22:[function(require,module,exports){"use strict";var getDay=Date.prototype.getDay;var tryDateObject=function tryDateObject(value){try{getDay.call(value);return true}catch(e){return false}};var toStr=Object.prototype.toString;var dateClass="[object Date]";var hasToStringTag=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";module.exports=function isDateObject(value){if(typeof value!=="object"||value===null){return false}return hasToStringTag?tryDateObject(value):toStr.call(value)===dateClass}},{}],23:[function(require,module,exports){"use strict";var has=require("has");var regexExec=RegExp.prototype.exec;var gOPD=Object.getOwnPropertyDescriptor;var tryRegexExecCall=function tryRegexExec(value){try{var lastIndex=value.lastIndex;value.lastIndex=0;regexExec.call(value);return true}catch(e){return false}finally{value.lastIndex=lastIndex}};var toStr=Object.prototype.toString;var regexClass="[object RegExp]";var hasToStringTag=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";module.exports=function isRegex(value){if(!value||typeof value!=="object"){return false}if(!hasToStringTag){return toStr.call(value)===regexClass}var descriptor=gOPD(value,"lastIndex");var hasLastIndexDataProperty=descriptor&&has(descriptor,"value");if(!hasLastIndexDataProperty){return false}return tryRegexExecCall(value)}},{has:20}],24:[function(require,module,exports){"use strict";var toStr=Object.prototype.toString;var hasSymbols=typeof Symbol==="function"&&typeof Symbol()==="symbol";if(hasSymbols){var symToStr=Symbol.prototype.toString;var symStringRegex=/^Symbol\(.*\)$/;var isSymbolObject=function isSymbolObject(value){if(typeof value.valueOf()!=="symbol"){return false}return symStringRegex.test(symToStr.call(value))};module.exports=function isSymbol(value){if(typeof value==="symbol"){return true}if(toStr.call(value)!=="[object Symbol]"){return false}try{return isSymbolObject(value)}catch(e){return false}}}else{module.exports=function isSymbol(value){return false}}},{}],25:[function(require,module,exports){"use strict";var range;var NS_XHTML="http://www.w3.org/1999/xhtml";var doc=typeof document==="undefined"?undefined:document;var testEl=doc?doc.body||doc.createElement("div"):{};var actualHasAttributeNS;if(testEl.hasAttributeNS){actualHasAttributeNS=function(el,namespaceURI,name){return el.hasAttributeNS(namespaceURI,name)}}else if(testEl.hasAttribute){actualHasAttributeNS=function(el,namespaceURI,name){return el.hasAttribute(name)}}else{actualHasAttributeNS=function(el,namespaceURI,name){return el.getAttributeNode(namespaceURI,name)!=null}}var hasAttributeNS=actualHasAttributeNS;function toElement(str){if(!range&&doc.createRange){range=doc.createRange();range.selectNode(doc.body)}var fragment;if(range&&range.createContextualFragment){fragment=range.createContextualFragment(str)}else{fragment=doc.createElement("body");fragment.innerHTML=str}return fragment.childNodes[0]}function compareNodeNames(fromEl,toEl){var fromNodeName=fromEl.nodeName;var toNodeName=toEl.nodeName;if(fromNodeName===toNodeName){return true}if(toEl.actualize&&fromNodeName.charCodeAt(0)<91&&toNodeName.charCodeAt(0)>90){return fromNodeName===toNodeName.toUpperCase()}else{return false}}function createElementNS(name,namespaceURI){return!namespaceURI||namespaceURI===NS_XHTML?doc.createElement(name):doc.createElementNS(namespaceURI,name)}function moveChildren(fromEl,toEl){var curChild=fromEl.firstChild;while(curChild){var nextChild=curChild.nextSibling;toEl.appendChild(curChild);curChild=nextChild}return toEl}function morphAttrs(fromNode,toNode){var attrs=toNode.attributes;var i;var attr;var attrName;var attrNamespaceURI;var attrValue;var fromValue;for(i=attrs.length-1;i>=0;--i){attr=attrs[i];attrName=attr.name;attrNamespaceURI=attr.namespaceURI;attrValue=attr.value;if(attrNamespaceURI){attrName=attr.localName||attrName;fromValue=fromNode.getAttributeNS(attrNamespaceURI,attrName);if(fromValue!==attrValue){fromNode.setAttributeNS(attrNamespaceURI,attrName,attrValue)}}else{fromValue=fromNode.getAttribute(attrName);if(fromValue!==attrValue){fromNode.setAttribute(attrName,attrValue)}}}attrs=fromNode.attributes;for(i=attrs.length-1;i>=0;--i){attr=attrs[i];if(attr.specified!==false){attrName=attr.name;attrNamespaceURI=attr.namespaceURI;if(attrNamespaceURI){attrName=attr.localName||attrName;if(!hasAttributeNS(toNode,attrNamespaceURI,attrName)){fromNode.removeAttributeNS(attrNamespaceURI,attrName)}}else{if(!hasAttributeNS(toNode,null,attrName)){fromNode.removeAttribute(attrName)}}}}}function syncBooleanAttrProp(fromEl,toEl,name){if(fromEl[name]!==toEl[name]){fromEl[name]=toEl[name];if(fromEl[name]){fromEl.setAttribute(name,"")}else{fromEl.removeAttribute(name,"")}}}var specialElHandlers={OPTION:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"selected")},INPUT:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"checked");syncBooleanAttrProp(fromEl,toEl,"disabled");if(fromEl.value!==toEl.value){fromEl.value=toEl.value}if(!hasAttributeNS(toEl,null,"value")){fromEl.removeAttribute("value")}},TEXTAREA:function(fromEl,toEl){var newValue=toEl.value;if(fromEl.value!==newValue){fromEl.value=newValue}if(fromEl.firstChild){if(newValue===""&&fromEl.firstChild.nodeValue===fromEl.placeholder){return}fromEl.firstChild.nodeValue=newValue}},SELECT:function(fromEl,toEl){if(!hasAttributeNS(toEl,null,"multiple")){var selectedIndex=-1;var i=0;var curChild=toEl.firstChild;while(curChild){var nodeName=curChild.nodeName;if(nodeName&&nodeName.toUpperCase()==="OPTION"){if(hasAttributeNS(curChild,null,"selected")){selectedIndex=i;break}i++}curChild=curChild.nextSibling}fromEl.selectedIndex=i}}};var ELEMENT_NODE=1;var TEXT_NODE=3;var COMMENT_NODE=8;function noop(){}function defaultGetNodeKey(node){return node.id}function morphdomFactory(morphAttrs){return function morphdom(fromNode,toNode,options){if(!options){options={}}if(typeof toNode==="string"){if(fromNode.nodeName==="#document"||fromNode.nodeName==="HTML"){var toNodeHtml=toNode;toNode=doc.createElement("html");toNode.innerHTML=toNodeHtml}else{toNode=toElement(toNode)}}var getNodeKey=options.getNodeKey||defaultGetNodeKey;var onBeforeNodeAdded=options.onBeforeNodeAdded||noop;var onNodeAdded=options.onNodeAdded||noop;var onBeforeElUpdated=options.onBeforeElUpdated||noop;var onElUpdated=options.onElUpdated||noop;var onBeforeNodeDiscarded=options.onBeforeNodeDiscarded||noop;var onNodeDiscarded=options.onNodeDiscarded||noop;var onBeforeElChildrenUpdated=options.onBeforeElChildrenUpdated||noop;var childrenOnly=options.childrenOnly===true;var fromNodesLookup={};var keyedRemovalList;function addKeyedRemoval(key){if(keyedRemovalList){keyedRemovalList.push(key)}else{keyedRemovalList=[key]}}function walkDiscardedChildNodes(node,skipKeyedNodes){if(node.nodeType===ELEMENT_NODE){var curChild=node.firstChild;while(curChild){var key=undefined;if(skipKeyedNodes&&(key=getNodeKey(curChild))){addKeyedRemoval(key)}else{onNodeDiscarded(curChild);if(curChild.firstChild){walkDiscardedChildNodes(curChild,skipKeyedNodes)}}curChild=curChild.nextSibling}}}function removeNode(node,parentNode,skipKeyedNodes){if(onBeforeNodeDiscarded(node)===false){return}if(parentNode){parentNode.removeChild(node)}onNodeDiscarded(node);walkDiscardedChildNodes(node,skipKeyedNodes)}function indexTree(node){if(node.nodeType===ELEMENT_NODE){var curChild=node.firstChild;while(curChild){var key=getNodeKey(curChild);if(key){fromNodesLookup[key]=curChild}indexTree(curChild);curChild=curChild.nextSibling}}}indexTree(fromNode);function handleNodeAdded(el){onNodeAdded(el);var curChild=el.firstChild;while(curChild){var nextSibling=curChild.nextSibling;var key=getNodeKey(curChild);if(key){var unmatchedFromEl=fromNodesLookup[key];if(unmatchedFromEl&&compareNodeNames(curChild,unmatchedFromEl)){curChild.parentNode.replaceChild(unmatchedFromEl,curChild);morphEl(unmatchedFromEl,curChild)}}handleNodeAdded(curChild);curChild=nextSibling}}function morphEl(fromEl,toEl,childrenOnly){var toElKey=getNodeKey(toEl);var curFromNodeKey;if(toElKey){delete fromNodesLookup[toElKey]}if(toNode.isSameNode&&toNode.isSameNode(fromNode)){return}if(!childrenOnly){if(onBeforeElUpdated(fromEl,toEl)===false){return}morphAttrs(fromEl,toEl);onElUpdated(fromEl);if(onBeforeElChildrenUpdated(fromEl,toEl)===false){return}}if(fromEl.nodeName!=="TEXTAREA"){var curToNodeChild=toEl.firstChild;var curFromNodeChild=fromEl.firstChild;var curToNodeKey;var fromNextSibling;var toNextSibling;var matchingFromEl;outer:while(curToNodeChild){toNextSibling=curToNodeChild.nextSibling;curToNodeKey=getNodeKey(curToNodeChild);while(curFromNodeChild){fromNextSibling=curFromNodeChild.nextSibling;if(curToNodeChild.isSameNode&&curToNodeChild.isSameNode(curFromNodeChild)){curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling;continue outer}curFromNodeKey=getNodeKey(curFromNodeChild);var curFromNodeType=curFromNodeChild.nodeType;var isCompatible=undefined;if(curFromNodeType===curToNodeChild.nodeType){if(curFromNodeType===ELEMENT_NODE){if(curToNodeKey){if(curToNodeKey!==curFromNodeKey){if(matchingFromEl=fromNodesLookup[curToNodeKey]){if(curFromNodeChild.nextSibling===matchingFromEl){isCompatible=false}else{fromEl.insertBefore(matchingFromEl,curFromNodeChild);fromNextSibling=curFromNodeChild.nextSibling;if(curFromNodeKey){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=matchingFromEl}}else{isCompatible=false}}}else if(curFromNodeKey){isCompatible=false}isCompatible=isCompatible!==false&&compareNodeNames(curFromNodeChild,curToNodeChild);if(isCompatible){morphEl(curFromNodeChild,curToNodeChild)}}else if(curFromNodeType===TEXT_NODE||curFromNodeType==COMMENT_NODE){isCompatible=true;curFromNodeChild.nodeValue=curToNodeChild.nodeValue}}if(isCompatible){curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling;continue outer}if(curFromNodeKey){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=fromNextSibling}if(curToNodeKey&&(matchingFromEl=fromNodesLookup[curToNodeKey])&&compareNodeNames(matchingFromEl,curToNodeChild)){fromEl.appendChild(matchingFromEl);morphEl(matchingFromEl,curToNodeChild)}else{var onBeforeNodeAddedResult=onBeforeNodeAdded(curToNodeChild);if(onBeforeNodeAddedResult!==false){if(onBeforeNodeAddedResult){curToNodeChild=onBeforeNodeAddedResult}if(curToNodeChild.actualize){curToNodeChild=curToNodeChild.actualize(fromEl.ownerDocument||doc)}fromEl.appendChild(curToNodeChild);handleNodeAdded(curToNodeChild)}}curToNodeChild=toNextSibling;curFromNodeChild=fromNextSibling}while(curFromNodeChild){fromNextSibling=curFromNodeChild.nextSibling;if(curFromNodeKey=getNodeKey(curFromNodeChild)){addKeyedRemoval(curFromNodeKey)}else{removeNode(curFromNodeChild,fromEl,true)}curFromNodeChild=fromNextSibling}}var specialElHandler=specialElHandlers[fromEl.nodeName];if(specialElHandler){specialElHandler(fromEl,toEl)}}var morphedNode=fromNode;var morphedNodeType=morphedNode.nodeType;var toNodeType=toNode.nodeType;if(!childrenOnly){if(morphedNodeType===ELEMENT_NODE){if(toNodeType===ELEMENT_NODE){if(!compareNodeNames(fromNode,toNode)){onNodeDiscarded(fromNode);morphedNode=moveChildren(fromNode,createElementNS(toNode.nodeName,toNode.namespaceURI))}}else{morphedNode=toNode}}else if(morphedNodeType===TEXT_NODE||morphedNodeType===COMMENT_NODE){if(toNodeType===morphedNodeType){morphedNode.nodeValue=toNode.nodeValue;return morphedNode}else{morphedNode=toNode}}}if(morphedNode===toNode){onNodeDiscarded(fromNode)}else{morphEl(morphedNode,toNode,childrenOnly);if(keyedRemovalList){for(var i=0,len=keyedRemovalList.length;i<len;i++){var elToRemove=fromNodesLookup[keyedRemovalList[i]];if(elToRemove){removeNode(elToRemove,elToRemove.parentNode,false)}}}}if(!childrenOnly&&morphedNode!==fromNode&&fromNode.parentNode){if(morphedNode.actualize){morphedNode=morphedNode.actualize(fromNode.ownerDocument||doc)}fromNode.parentNode.replaceChild(morphedNode,fromNode)}return morphedNode}}var morphdom=morphdomFactory(morphAttrs);module.exports=morphdom},{}],26:[function(require,module,exports){"use strict";var has=Object.prototype.hasOwnProperty;var toStr=Object.prototype.toString;var slice=Array.prototype.slice;var isArgs=require("./isArguments");var isEnumerable=Object.prototype.propertyIsEnumerable;var hasDontEnumBug=!isEnumerable.call({toString:null},"toString");var hasProtoEnumBug=isEnumerable.call(function(){},"prototype");var dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var equalsConstructorPrototype=function(o){var ctor=o.constructor;return ctor&&ctor.prototype===o};var excludedKeys={$console:true,$external:true,$frame:true,$frameElement:true,$frames:true,$innerHeight:true,$innerWidth:true,$outerHeight:true,$outerWidth:true,$pageXOffset:true,$pageYOffset:true,$parent:true,$scrollLeft:true,$scrollTop:true,$scrollX:true,$scrollY:true,$self:true,$webkitIndexedDB:true,$webkitStorageInfo:true,$window:true};var hasAutomationEqualityBug=function(){if(typeof window==="undefined"){return false}for(var k in window){try{if(!excludedKeys["$"+k]&&has.call(window,k)&&window[k]!==null&&typeof window[k]==="object"){try{equalsConstructorPrototype(window[k])}catch(e){return true}}}catch(e){return true}}return false}();var equalsConstructorPrototypeIfNotBuggy=function(o){if(typeof window==="undefined"||!hasAutomationEqualityBug){return equalsConstructorPrototype(o)}try{return equalsConstructorPrototype(o)}catch(e){ | ||
return false}};var keysShim=function keys(object){var isObject=object!==null&&typeof object==="object";var isFunction=toStr.call(object)==="[object Function]";var isArguments=isArgs(object);var isString=isObject&&toStr.call(object)==="[object String]";var theKeys=[];if(!isObject&&!isFunction&&!isArguments){throw new TypeError("Object.keys called on a non-object")}var skipProto=hasProtoEnumBug&&isFunction;if(isString&&object.length>0&&!has.call(object,0)){for(var i=0;i<object.length;++i){theKeys.push(String(i))}}if(isArguments&&object.length>0){for(var j=0;j<object.length;++j){theKeys.push(String(j))}}else{for(var name in object){if(!(skipProto&&name==="prototype")&&has.call(object,name)){theKeys.push(String(name))}}}if(hasDontEnumBug){var skipConstructor=equalsConstructorPrototypeIfNotBuggy(object);for(var k=0;k<dontEnums.length;++k){if(!(skipConstructor&&dontEnums[k]==="constructor")&&has.call(object,dontEnums[k])){theKeys.push(dontEnums[k])}}}return theKeys};keysShim.shim=function shimObjectKeys(){if(Object.keys){var keysWorksWithArguments=function(){return(Object.keys(arguments)||"").length===2}(1,2);if(!keysWorksWithArguments){var originalKeys=Object.keys;Object.keys=function keys(object){if(isArgs(object)){return originalKeys(slice.call(object))}else{return originalKeys(object)}}}}else{Object.keys=keysShim}return Object.keys||keysShim};module.exports=keysShim},{"./isArguments":27}],27:[function(require,module,exports){"use strict";var toStr=Object.prototype.toString;module.exports=function isArguments(value){var str=toStr.call(value);var isArgs=str==="[object Arguments]";if(!isArgs){isArgs=str!=="[object Array]"&&value!==null&&typeof value==="object"&&typeof value.length==="number"&&value.length>=0&&toStr.call(value.callee)==="[object Function]"}return isArgs}},{}],28:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var _util=require("./util");function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}else{return Array.from(arr)}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var morphdom=require("morphdom");var find=require("array.prototype.find");var eventType="input paste copy click change keydown keyup keypress contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend focus";var bindType="input change click";var dataAction=eventType.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";var aTemplate=function(){function aTemplate(opt){var _this=this;_classCallCheck(this,aTemplate);this.atemplate=[];if(opt){Object.keys(opt).forEach(function(key){_this[key]=opt[key]})}if(!this.data){this.data={}}if(!this.templates){this.templates=[]}var templates=this.templates;var length=templates.length;for(var i=0,n=length;i<n;i+=1){var template=this.templates[i];var html=(0,_util.selector)("#"+template).innerHTML;this.atemplate.push({id:template,html:html,binded:false})}}_createClass(aTemplate,[{key:"addDataBind",value:function addDataBind(ele){var _this2=this;(0,_util.on)(ele,"[data-bind]",bindType,function(e){var target=e.delegateTarget;var data=target.getAttribute("data-bind");var attr=target.getAttribute("href");var value=target.value;if(attr){value=value.replace("#","")}if(target.getAttribute("type")==="checkbox"){(function(){var arr=[];var items=document.querySelectorAll('[data-bind="'+data+'"]');[].forEach.call(items,function(item){if(item.checked){arr.push(item.value)}})})()}else if(target.getAttribute("type")!=="radio"){_this2.updateDataByString(data,value)}})}},{key:"addActionBind",value:function addActionBind(ele){var _this3=this;(0,_util.on)(ele,dataAction,eventType,function(e){var target=e.delegateTarget;var events=eventType.split(" ");var action="action";events.forEach(function(event){if(target.getAttribute("data-action-"+event)){if(e.type===event){action+="-"+event}}});var string=target.getAttribute("data-"+action);if(!string){return}var method=string.replace(/\(.*?\);?/,"");var parameter=string.replace(/(.*?)\((.*?)\);?/,"$2");var pts=parameter.split(",");_this3.e=e;if(_this3.method&&_this3.method[method]){var _method;(_method=_this3.method)[method].apply(_method,_toConsumableArray(pts))}else if(_this3[method]){_this3[method].apply(_this3,_toConsumableArray(pts))}})}},{key:"addTemplate",value:function addTemplate(id,html){this.atemplate.push({id:id,html:html,binded:false});this.templates.push(id)}},{key:"getData",value:function getData(){return JSON.parse(JSON.stringify(this.data))}},{key:"saveData",value:function saveData(key){var data=JSON.stringify(this.data);localStorage.setItem(key,data)}},{key:"setData",value:function setData(opt){var _this4=this;Object.keys(opt).forEach(function(key){if(typeof opt[key]!=="function"){_this4.data[key]=opt[key]}})}},{key:"loadData",value:function loadData(key){var data=JSON.parse(localStorage.getItem(key));if(data){this.setData(data)}}},{key:"getRand",value:function getRand(a,b){return~~(Math.random()*(b-a+1))+a}},{key:"getRandText",value:function getRandText(limit){var ret="";var strings="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var length=strings.length;for(var i=0;i<limit;i+=1){ret+=strings.charAt(Math.floor(this.getRand(0,length)))}return ret}},{key:"getDataFromObj",value:function getDataFromObj(s,o){s=s.replace(/\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\]/g,".$1");s=s.replace(/^\./,"");var a=s.split(".");while(a.length){var n=a.shift();if(n in o){o=o[n]}else{return null}}return o}},{key:"getDataByString",value:function getDataByString(s){var o=this.data;return this.getDataFromObj(s,o)}},{key:"updateDataByString",value:function updateDataByString(path,newValue){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}object[stack.shift()]=newValue}},{key:"removeDataByString",value:function removeDataByString(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}}},{key:"resolveBlock",value:function resolveBlock(html,item,i){var that=this;var touchs=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+) -->/g);var touchnots=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+) -->/g);var exists=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist -->/g);var empties=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty -->/g);if(touchs){for(var k=0,n=touchs.length;k<n;k+=1){var start=touchs[k];start=start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/,"($1):touch#($2)");var end=start.replace(/BEGIN/,"END");var reg=new RegExp(start+"(([\\n\\r\\t]|.)*?)"+end,"g");html=html.replace(reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(""+itemkey===val){return next}return""})}}if(touchnots){for(var _k=0,_n=touchnots.length;_k<_n;_k+=1){var _start=touchnots[_k];_start=_start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/,"($1):touchnot#($2)");var _end=_start.replace(/BEGIN/,"END");var _reg=new RegExp(_start+"(([\\n\\r\\t]|.)*?)"+_end,"g");html=html.replace(_reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(""+itemkey!==val){return next}return""})}}if(exists){for(var _k2=0,_n2=exists.length;_k2<_n2;_k2+=1){var _start2=exists[_k2];_start2=_start2.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist/,"($1):exist");var _end2=_start2.replace(/BEGIN/,"END");var _reg2=new RegExp(_start2+"(([\\n\\r\\t]|.)*?)"+_end2,"g");html=html.replace(_reg2,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey||itemkey===0){return next}return""})}}if(empties){for(var _k3=0,_n3=empties.length;_k3<_n3;_k3+=1){var _start3=empties[_k3];_start3=_start3.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty/,"($1):empty");var _end3=_start3.replace(/BEGIN/,"END");var empty=new RegExp(_start3+"(([\\n\\r\\t]|.)*?)"+_end3,"g");html=html.replace(empty,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(!itemkey&&itemkey!==0){return next}return""})}}html=html.replace(/{([\w\-\.ぁ-んァ-ヶ亜-熙]+)}(\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\])*/g,function(n,key3,key4,converter){var data=void 0;if(""+key3==="i"){data=i}else if(item[key3]||item[key3]===0){if(typeof item[key3]==="function"){data=item[key3].apply(that)}else{data=item[key3]}}else{if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,"")}return""}if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,data)}return data});return html}},{key:"resolveAbsBlock",value:function resolveAbsBlock(html){var that=this;html=html.replace(/{(.*?)}/g,function(n,key3){var data=that.getDataByString(key3);if(typeof data!=="undefined"){if(typeof data==="function"){return data.apply(that)}return data}return n});return html}},{key:"resolveInclude",value:function resolveInclude(html){var include=/<!-- #include id="(.*?)" -->/g;html=html.replace(include,function(m,key){return(0,_util.selector)("#"+key).innerHTML});return html}},{key:"resolveWith",value:function resolveWith(html){var width=/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):with -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+):with -->/g;html=html.replace(width,function(m,key){m=m.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+key+".$1'");return m});return html}},{key:"resolveLoop",value:function resolveLoop(html){var loop=/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->/g;var that=this;html=html.replace(loop,function(m,key,val){var keyItem=that.getDataByString(key);var keys=[];if(typeof keyItem==="function"){keys=keyItem.apply(that)}else{keys=keyItem}var ret="";if(keys instanceof Array){for(var i=0,n=keys.length;i<n;i+=1){ret+=that.resolveBlock(val,keys[i],i)}}ret=ret.replace(/\\([^\\])/g,"$1");return ret});return html}},{key:"removeData",value:function removeData(arr){var data=this.data;Object.keys(data).forEach(function(i){for(var t=0,n=arr.length;t<n;t+=1){if(i===arr[t]){delete data[i]}}});return this}},{key:"hasLoop",value:function hasLoop(txt){var loop=/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->/g;if(txt.match(loop)){return true}return false}},{key:"getHtml",value:function getHtml(query,row){var template=find(this.atemplate,function(item){return item.id===query});var html="";if(template&&template.html){html=template.html}if(row){html=query}if(!html){return""}var data=this.data;html=this.resolveInclude(html);html=this.resolveWith(html);while(this.hasLoop(html)){html=this.resolveLoop(html)}html=this.resolveBlock(html,data);html=html.replace(/\\([^\\])/g,"$1");html=this.resolveAbsBlock(html);return html.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function update(){var _this5=this;var renderWay=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"html";var part=arguments[1];var templates=this.templates;if(this.beforeUpdated){this.beforeUpdated()}var _loop=function _loop(i,n){var tem=templates[i];var query="#"+tem;var html=_this5.getHtml(tem);var target=(0,_util.selector)("[data-id='"+tem+"']");if(!target){(0,_util.selector)(query).insertAdjacentHTML("afterend",'<div data-id="'+tem+'"></div>');if(renderWay==="text"){(0,_util.selector)("[data-id='"+tem+"']").innerText=html}else{(0,_util.selector)("[data-id='"+tem+"']").innerHTML=html}}else if(renderWay==="text"){target.innerText=html}else if(part){var parser=new DOMParser;var doc=parser.parseFromString(html,"text/html");var partHtml=doc.querySelector(part).outerHTML;morphdom(target.querySelector(part),partHtml)}else{morphdom(target,"<div data-id='"+tem+"'>"+html+"</div>")}var template=find(_this5.atemplate,function(item){return item.id===tem});if(!template.binded){template.binded=true;_this5.addDataBind((0,_util.selector)("[data-id='"+tem+"']"));_this5.addActionBind((0,_util.selector)("[data-id='"+tem+"']"))}};for(var i=0,n=templates.length;i<n;i+=1){_loop(i,n)}this.updateBindingData(part);if(this.onUpdated){this.onUpdated(part)}return this}},{key:"updateBindingData",value:function updateBindingData(part){var _this6=this;var templates=this.templates;for(var i=0,n=templates.length;i<n;i+=1){var temp=templates[i];var _template=(0,_util.selector)("[data-id='"+temp+"']");if(part){_template=_template.querySelector(part)}var binds=_template.querySelectorAll("[data-bind]");[].forEach.call(binds,function(item){var data=_this6.getDataByString(item.getAttribute("data-bind"));if(item.getAttribute("type")==="checkbox"||item.getAttribute("type")==="radio"){if(data===item.value){item.checked=true}}else{item.value=data}});var onewaybinds=_template.querySelectorAll("[data-bind-oneway]");[].forEach.call(onewaybinds,function(item){var data=_this6.getDataByString(item.getAttribute("data-bind-oneway"));if(item.getAttribute("type")==="checkbox"||item.getAttribute("type")==="radio"){if(data===item.value){item.checked=true}}else{item.value=data}})}return this}},{key:"applyMethod",value:function applyMethod(method){var _method2;for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}return(_method2=this.method)[method].apply(_method2,args)}},{key:"getComputedProp",value:function getComputedProp(prop){return this.data[prop].apply(this)}},{key:"remove",value:function remove(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}return this}}]);return aTemplate}();exports.default=aTemplate;module.exports=exports["default"]},{"./util":29,"array.prototype.find":2,morphdom:25}],29:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var matches=exports.matches=function matches(element,query){var matches=(element.document||element.ownerDocument).querySelectorAll(query);var i=matches.length;while(--i>=0&&matches.item(i)!==element){}return i>-1};var selector=exports.selector=function selector(_selector){return document.querySelector(_selector)};var findAncestor=exports.findAncestor=function findAncestor(element,selector){if(typeof element.closest==="function"){return element.closest(selector)||null}while(element&&element!==document){if(matches(element,selector)){return element}element=element.parentElement}return null};var on=exports.on=function on(element,query,eventNames,fn){var events=eventNames.split(" ");events.forEach(function(event){element.addEventListener(event,function(e){var target=e.target;var delegateTarget=findAncestor(e.target,query);if(delegateTarget){e.delegateTarget=delegateTarget;fn(e)}})})}},{}]},{},[28])(28)}); | ||
return false}};var keysShim=function keys(object){var isObject=object!==null&&typeof object==="object";var isFunction=toStr.call(object)==="[object Function]";var isArguments=isArgs(object);var isString=isObject&&toStr.call(object)==="[object String]";var theKeys=[];if(!isObject&&!isFunction&&!isArguments){throw new TypeError("Object.keys called on a non-object")}var skipProto=hasProtoEnumBug&&isFunction;if(isString&&object.length>0&&!has.call(object,0)){for(var i=0;i<object.length;++i){theKeys.push(String(i))}}if(isArguments&&object.length>0){for(var j=0;j<object.length;++j){theKeys.push(String(j))}}else{for(var name in object){if(!(skipProto&&name==="prototype")&&has.call(object,name)){theKeys.push(String(name))}}}if(hasDontEnumBug){var skipConstructor=equalsConstructorPrototypeIfNotBuggy(object);for(var k=0;k<dontEnums.length;++k){if(!(skipConstructor&&dontEnums[k]==="constructor")&&has.call(object,dontEnums[k])){theKeys.push(dontEnums[k])}}}return theKeys};keysShim.shim=function shimObjectKeys(){if(Object.keys){var keysWorksWithArguments=function(){return(Object.keys(arguments)||"").length===2}(1,2);if(!keysWorksWithArguments){var originalKeys=Object.keys;Object.keys=function keys(object){if(isArgs(object)){return originalKeys(slice.call(object))}else{return originalKeys(object)}}}}else{Object.keys=keysShim}return Object.keys||keysShim};module.exports=keysShim},{"./isArguments":27}],27:[function(require,module,exports){"use strict";var toStr=Object.prototype.toString;module.exports=function isArguments(value){var str=toStr.call(value);var isArgs=str==="[object Arguments]";if(!isArgs){isArgs=str!=="[object Array]"&&value!==null&&typeof value==="object"&&typeof value.length==="number"&&value.length>=0&&toStr.call(value.callee)==="[object Function]"}return isArgs}},{}],28:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var _util=require("./util");function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}else{return Array.from(arr)}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var morphdom=require("morphdom");var find=require("array.prototype.find");var eventType="input paste copy click change keydown keyup keypress contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend focus";var bindType="input change click";var dataAction=eventType.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";var aTemplate=function(){function aTemplate(opt){var _this=this;_classCallCheck(this,aTemplate);this.atemplate=[];if(opt){Object.keys(opt).forEach(function(key){_this[key]=opt[key]})}if(!this.data){this.data={}}if(!this.templates){this.templates=[]}var templates=this.templates;var length=templates.length;for(var i=0,n=length;i<n;i+=1){var template=this.templates[i];var html=(0,_util.selector)("#"+template).innerHTML;this.atemplate.push({id:template,html:html,binded:false})}}_createClass(aTemplate,[{key:"addDataBind",value:function addDataBind(ele){var _this2=this;(0,_util.on)(ele,"[data-bind]",bindType,function(e){var target=e.delegateTarget;var data=target.getAttribute("data-bind");var attr=target.getAttribute("href");var value=target.value;if(attr){value=value.replace("#","")}if(target.getAttribute("type")==="checkbox"){(function(){var arr=[];var items=document.querySelectorAll('[data-bind="'+data+'"]');[].forEach.call(items,function(item){if(item.checked){arr.push(item.value)}})})()}else if(target.getAttribute("type")!=="radio"){_this2.updateDataByString(data,value)}})}},{key:"addActionBind",value:function addActionBind(ele){var _this3=this;(0,_util.on)(ele,dataAction,eventType,function(e){var target=e.delegateTarget;var events=eventType.split(" ");var action="action";events.forEach(function(event){if(target.getAttribute("data-action-"+event)){if(e.type===event){action+="-"+event}}});var string=target.getAttribute("data-"+action);if(!string){return}var method=string.replace(/\(.*?\);?/,"");var parameter=string.replace(/(.*?)\((.*?)\);?/,"$2");var pts=parameter.split(",");_this3.e=e;if(_this3.method&&_this3.method[method]){var _method;(_method=_this3.method)[method].apply(_method,_toConsumableArray(pts))}else if(_this3[method]){_this3[method].apply(_this3,_toConsumableArray(pts))}})}},{key:"addTemplate",value:function addTemplate(id,html){this.atemplate.push({id:id,html:html,binded:false});this.templates.push(id)}},{key:"getData",value:function getData(){return JSON.parse(JSON.stringify(this.data))}},{key:"saveData",value:function saveData(key){var data=JSON.stringify(this.data);localStorage.setItem(key,data)}},{key:"setData",value:function setData(opt){var _this4=this;Object.keys(opt).forEach(function(key){if(typeof opt[key]!=="function"){_this4.data[key]=opt[key]}})}},{key:"loadData",value:function loadData(key){var data=JSON.parse(localStorage.getItem(key));if(data){this.setData(data)}}},{key:"getRand",value:function getRand(a,b){return~~(Math.random()*(b-a+1))+a}},{key:"getRandText",value:function getRandText(limit){var ret="";var strings="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var length=strings.length;for(var i=0;i<limit;i+=1){ret+=strings.charAt(Math.floor(this.getRand(0,length)))}return ret}},{key:"getDataFromObj",value:function getDataFromObj(s,o){s=s.replace(/\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\]/g,".$1");s=s.replace(/^\./,"");var a=s.split(".");while(a.length){var n=a.shift();if(n in o){o=o[n]}else{return null}}return o}},{key:"getDataByString",value:function getDataByString(s){var o=this.data;return this.getDataFromObj(s,o)}},{key:"updateDataByString",value:function updateDataByString(path,newValue){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}object[stack.shift()]=newValue}},{key:"removeDataByString",value:function removeDataByString(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}}},{key:"resolveBlock",value:function resolveBlock(html,item,i){var that=this;var touchs=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+) -->/g);var touchnots=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+) -->/g);var exists=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist -->/g);var empties=html.match(/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty -->/g);if(touchs){for(var k=0,n=touchs.length;k<n;k+=1){var start=touchs[k];start=start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/,"($1):touch#($2)");var end=start.replace(/BEGIN/,"END");var reg=new RegExp(start+"(([\\n\\r\\t]|.)*?)"+end,"g");html=html.replace(reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(""+itemkey===val){return next}return""})}}if(touchnots){for(var _k=0,_n=touchnots.length;_k<_n;_k+=1){var _start=touchnots[_k];_start=_start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/,"($1):touchnot#($2)");var _end=_start.replace(/BEGIN/,"END");var _reg=new RegExp(_start+"(([\\n\\r\\t]|.)*?)"+_end,"g");html=html.replace(_reg,function(m,key2,val,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(""+itemkey!==val){return next}return""})}}if(exists){for(var _k2=0,_n2=exists.length;_k2<_n2;_k2+=1){var _start2=exists[_k2];_start2=_start2.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist/,"($1):exist");var _end2=_start2.replace(/BEGIN/,"END");var _reg2=new RegExp(_start2+"(([\\n\\r\\t]|.)*?)"+_end2,"g");html=html.replace(_reg2,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(itemkey||itemkey===0){return next}return""})}}if(empties){for(var _k3=0,_n3=empties.length;_k3<_n3;_k3+=1){var _start3=empties[_k3];_start3=_start3.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty/,"($1):empty");var _end3=_start3.replace(/BEGIN/,"END");var empty=new RegExp(_start3+"(([\\n\\r\\t]|.)*?)"+_end3,"g");html=html.replace(empty,function(m,key2,next){var itemkey=typeof item[key2]==="function"?item[key2].apply(that):that.getDataFromObj(key2,item);if(!itemkey&&itemkey!==0){return next}return""})}}html=html.replace(/{([\w\-\.ぁ-んァ-ヶ亜-熙]+)}(\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\])*/g,function(n,key3,key4,converter){var data=void 0;if(""+key3==="i"){data=i}else if(item[key3]||item[key3]===0){if(typeof item[key3]==="function"){data=item[key3].apply(that)}else{data=item[key3]}}else{if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,"")}return""}if(converter&&that.convert&&that.convert[converter]){return that.convert[converter].call(that,data)}return data});return html}},{key:"resolveAbsBlock",value:function resolveAbsBlock(html){var that=this;html=html.replace(/{(.*?)}/g,function(n,key3){var data=that.getDataByString(key3);if(typeof data!=="undefined"){if(typeof data==="function"){return data.apply(that)}return data}return n});return html}},{key:"resolveInclude",value:function resolveInclude(html){var include=/<!-- #include id="(.*?)" -->/g;html=html.replace(include,function(m,key){return(0,_util.selector)("#"+key).innerHTML});return html}},{key:"resolveWith",value:function resolveWith(html){var width=/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+):with -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+):with -->/g;html=html.replace(width,function(m,key){m=m.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+key+".$1'");return m});return html}},{key:"resolveLoop",value:function resolveLoop(html){var loop=/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->/g;var that=this;html=html.replace(loop,function(m,key,val){var keyItem=that.getDataByString(key);var keys=[];if(typeof keyItem==="function"){keys=keyItem.apply(that)}else{keys=keyItem}var ret="";if(keys instanceof Array){for(var i=0,n=keys.length;i<n;i+=1){ret+=that.resolveBlock(val,keys[i],i)}}ret=ret.replace(/\\([^\\])/g,"$1");return ret});return html}},{key:"removeData",value:function removeData(arr){var data=this.data;Object.keys(data).forEach(function(i){for(var t=0,n=arr.length;t<n;t+=1){if(i===arr[t]){delete data[i]}}});return this}},{key:"hasLoop",value:function hasLoop(txt){var loop=/<!-- BEGIN ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->(([\n\r\t]|.)*?)<!-- END ([\w\-\.ぁ-んァ-ヶ亜-熙]+?):loop -->/g;if(txt.match(loop)){return true}return false}},{key:"getHtml",value:function getHtml(query,row){var template=find(this.atemplate,function(item){return item.id===query});var html="";if(template&&template.html){html=template.html}if(row){html=query}if(!html){return""}var data=this.data;html=this.resolveInclude(html);html=this.resolveWith(html);while(this.hasLoop(html)){html=this.resolveLoop(html)}html=this.resolveBlock(html,data);html=html.replace(/\\([^\\])/g,"$1");html=this.resolveAbsBlock(html);return html.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function update(){var _this5=this;var renderWay=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"html";var part=arguments[1];var templates=this.templates;if(this.beforeUpdated){this.beforeUpdated()}var _loop=function _loop(i,n){var tem=templates[i];var query="#"+tem;var html=_this5.getHtml(tem);var target=(0,_util.selector)("[data-id='"+tem+"']");if(!target){(0,_util.selector)(query).insertAdjacentHTML("afterend",'<div data-id="'+tem+'"></div>');if(renderWay==="text"){(0,_util.selector)("[data-id='"+tem+"']").innerText=html}else{(0,_util.selector)("[data-id='"+tem+"']").innerHTML=html}}else if(renderWay==="text"){target.innerText=html}else if(part){var doc=document.createElement("div");doc.innerHTML=html;var partHtml=doc.querySelector(part).outerHTML;morphdom(target.querySelector(part),partHtml)}else{morphdom(target,"<div data-id='"+tem+"'>"+html+"</div>")}var template=find(_this5.atemplate,function(item){return item.id===tem});if(!template.binded){template.binded=true;_this5.addDataBind((0,_util.selector)("[data-id='"+tem+"']"));_this5.addActionBind((0,_util.selector)("[data-id='"+tem+"']"))}};for(var i=0,n=templates.length;i<n;i+=1){_loop(i,n)}this.updateBindingData(part);if(this.onUpdated){this.onUpdated(part)}return this}},{key:"updateBindingData",value:function updateBindingData(part){var _this6=this;var templates=this.templates;for(var i=0,n=templates.length;i<n;i+=1){var temp=templates[i];var _template=(0,_util.selector)("[data-id='"+temp+"']");if(part){_template=_template.querySelector(part)}var binds=_template.querySelectorAll("[data-bind]");[].forEach.call(binds,function(item){var data=_this6.getDataByString(item.getAttribute("data-bind"));if(item.getAttribute("type")==="checkbox"||item.getAttribute("type")==="radio"){if(data===item.value){item.checked=true}}else{item.value=data}});var onewaybinds=_template.querySelectorAll("[data-bind-oneway]");[].forEach.call(onewaybinds,function(item){var data=_this6.getDataByString(item.getAttribute("data-bind-oneway"));if(item.getAttribute("type")==="checkbox"||item.getAttribute("type")==="radio"){if(data===item.value){item.checked=true}}else{item.value=data}})}return this}},{key:"applyMethod",value:function applyMethod(method){var _method2;for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}return(_method2=this.method)[method].apply(_method2,args)}},{key:"getComputedProp",value:function getComputedProp(prop){return this.data[prop].apply(this)}},{key:"remove",value:function remove(path){var object=this.data;var stack=path.split(".");while(stack.length>1){object=object[stack.shift()]}var shift=stack.shift();if(shift.match(/^\d+$/)){object.splice(Number(shift),1)}else{delete object[shift]}return this}}]);return aTemplate}();exports.default=aTemplate;module.exports=exports["default"]},{"./util":29,"array.prototype.find":2,morphdom:25}],29:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var matches=exports.matches=function matches(element,query){var matches=(element.document||element.ownerDocument).querySelectorAll(query);var i=matches.length;while(--i>=0&&matches.item(i)!==element){}return i>-1};var selector=exports.selector=function selector(_selector){return document.querySelector(_selector)};var findAncestor=exports.findAncestor=function findAncestor(element,selector){if(typeof element.closest==="function"){return element.closest(selector)||null}while(element&&element!==document){if(matches(element,selector)){return element}element=element.parentElement}return null};var on=exports.on=function on(element,query,eventNames,fn){var events=eventNames.split(" ");events.forEach(function(event){element.addEventListener(event,function(e){var target=e.target;var delegateTarget=findAncestor(e.target,query);if(delegateTarget){e.delegateTarget=delegateTarget;fn(e)}})})}},{}]},{},[28])(28)}); |
@@ -472,4 +472,4 @@ 'use strict'; | ||
} else if (part) { | ||
var parser = new DOMParser(); | ||
var doc = parser.parseFromString(html, 'text/html'); | ||
var doc = document.createElement('div'); | ||
doc.innerHTML = html; | ||
var partHtml = doc.querySelector(part).outerHTML; | ||
@@ -476,0 +476,0 @@ morphdom(target.querySelector(part), partHtml); |
{ | ||
"name": "a-template", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"author": "steelydylan", | ||
@@ -5,0 +5,0 @@ "description": "Simple Template Engine", |
@@ -411,4 +411,4 @@ import { selector, on } from './util'; | ||
} else if (part) { | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(html, 'text/html'); | ||
const doc = document.createElement('div'); | ||
doc.innerHTML = html; | ||
const partHtml = doc.querySelector(part).outerHTML; | ||
@@ -415,0 +415,0 @@ morphdom(target.querySelector(part), partHtml); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
311990
22