diff --git a/build.next.js b/build.next.js index af0f47e..b57a64d 100644 --- a/build.next.js +++ b/build.next.js @@ -40,14 +40,13 @@ const compileJs = (entry, output) => { const compileCss = (entry, output) => { let t1 = Date.now() const { css } = scss.renderSync({ ...cssOpt, file: entry }) - prefixer.process(css, { from: '', to: '' }).then(result => { - log( - '编译scss: %s, 耗时 %s ms', - chalk.green(entry), - chalk.yellow(Date.now() - t1) - ) - fs.echo(result.css, output) - }) + + log( + '编译scss: %s, 耗时 %s ms', + chalk.green(entry), + chalk.yellow(Date.now() - t1) + ) + fs.echo(css, output) } const compileHtm = (entry, output) => { diff --git a/src/css/reset.scss b/src/css/reset.scss index dc1e22b..c18a161 100644 --- a/src/css/reset.scss +++ b/src/css/reset.scss @@ -21,6 +21,9 @@ * 5 content list-style quotes ... 内容生成相关的属性 * */ +@font-face {font-family: "uifont"; + src: url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAACi8AAsAAAAAQkQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7ki2Y21hcAAAAYAAAAIsAAAFmD0RPQJnbHlmAAADrAAAIOAAADQUfTnGAWhlYWQAACSMAAAALwAAADYRPo9aaGhlYQAAJLwAAAAcAAAAJAfeA8tobXR4AAAk2AAAABUAAAEoJ+kAAGxvY2EAACTwAAAAlgAAAJbamc0CbWF4cAAAJYgAAAAfAAAAIAFqAJ9uYW1lAAAlqAAAAUUAAAJtPlT+fXBvc3QAACbwAAABygAAApE3JIzoeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGBwYKp4dYW7438AQw9zA0AAUZgTJAQDhxQw5eJzF1NdOVFEYxfH/0GzYULFh77333uV5sIwiN6gEJSRIsPfee+/1WdaFL4FrZnFDvNcz+ZGZ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WXCxsH9KFkEySWeel0GSk8JxaoXRKa0orvc4qbZ1bs9paOWlIyI4C06qLzpa7RUumn2uqwnTMvKqbkLfKqFb9Ie4aa2jiVBl6T8wpF53uO77X20A8iIUmFoTeZUG1lEu7NNoKmfVuCKyNB2UVDYENELlc6BGLjzDFUI5Z6pRhJFVgjW2Jl43wYbOyWpKfl9p2lIZVmO03rCOzsecnkUdQpmZtH4jFkcAqa0LWm6GRdSR82aSdkDx40TW8EVEF3sXVcZuo01iy+LYybesoYz7SlzYUIZ5kzbx3s/1soDUZCEW03NlOBWUNWwpv2IK05uOFrFJRob4jX6gyDo0Kd0H4rNSKTNwvVqOmxdCcV73WWSla8iJ+xm9Kawp86a2pk+Qvg6aySgAA') format('woff'); +} * {margin: 0;padding: 0;vertical-align: baseline;box-sizing:border-box;} /* HTML5 display-role reset for older browsers */ @@ -35,12 +38,8 @@ a:focus,input,button:focus,input:focus {outline:none;} ::-moz-focus-inner { border:none;outline:none; } -@font-face {font-family: "ui font"; - src: url('../font/ui-font.eot'); /* IE9*/ - src: url('../font/ui-font.ttf') format('truetype'); -} +[anot],[\:if],do-* {visibility:hidden;} -.do-ui-font {display:inline-block;font-family:"ui font" !important;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;} .do-fn-cl { *zoom: 1; } .do-fn-cl::after { content: "."; display: block; height: 0; clear: both; visibility: hidden; overflow:hidden;} .do-fn-clear {clear:both;display:inline;} @@ -54,3 +53,77 @@ a:focus,input,button:focus,input:focus {outline:none;} .do-fn-ell {overflow:hidden; white-space:nowrap; text-overflow:ellipsis } .do-st-thin {-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;} .do-st-hand {cursor:pointer;} + +[class^="do-icon-"], [class*=" do-icon-"] {display:inline-block;font-family:"uifont" !important;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;} +.do-icon-about:before { content: "\e673"; } +.do-icon-bad:before { content: "\e674"; } +.do-icon-deny:before { content: "\e676"; } +.do-icon-calendar:before { content: "\e675"; } +.do-icon-email:before { content: "\e677"; } +.do-icon-eye:before { content: "\e678"; } +.do-icon-fly:before { content: "\e679"; } +.do-icon-floppy:before { content: "\e67a"; } +.do-icon-good:before { content: "\e67b"; } +.do-icon-headset:before { content: "\e67d"; } +.do-icon-list:before { content: "\e682"; } +.do-icon-lock:before { content: "\e683"; } +.do-icon-menu-left:before { content: "\e684"; } +.do-icon-menu-right:before { content: "\e685"; } +.do-icon-minimize:before { content: "\e686"; } +.do-icon-phone:before { content: "\e688"; } +.do-icon-picture:before { content: "\e689"; } +.do-icon-pipe:before { content: "\e68a"; } +.do-icon-plus:before { content: "\e68b"; } +.do-icon-quote:before { content: "\e68d"; } +.do-icon-table:before { content: "\e690"; } +.do-icon-talk:before { content: "\e691"; } +.do-icon-time:before { content: "\e692"; } +.do-icon-download:before { content: "\e694"; } +.do-icon-upload:before { content: "\e695"; } +.do-icon-male:before { content: "\e696"; } +.do-icon-female:before { content: "\e697"; } +.do-icon-left:before { content: "\e698"; } +.do-icon-dbl-left:before { content: "\e699"; } +.do-icon-right:before { content: "\e69a"; } +.do-icon-dbl-right:before { content: "\e69b"; } +.do-icon-pin:before { content: "\e69c"; } +.do-icon-edit:before { content: "\e69d"; } +.do-icon-home:before { content: "\e69e"; } +.do-icon-chart:before { content: "\e69f"; } +.do-icon-folder-close:before { content: "\e6a0"; } +.do-icon-txt:before { content: "\e6a1"; } +.do-icon-folder-open:before { content: "\e6a2"; } +.do-icon-qr:before { content: "\e6a3"; } +.do-icon-setting:before { content: "\e6a4"; } +.do-icon-mute:before { content: "\e6a5"; } +.do-icon-chat:before { content: "\e6a6"; } +.do-icon-font:before { content: "\e6a7"; } +.do-icon-unmute:before { content: "\e6a8"; } +.do-icon-search:before { content: "\e6a9"; } +.do-icon-sad:before { content: "\e6aa"; } +.do-icon-trash:before { content: "\e6ab"; } +.do-icon-happy:before { content: "\e6ac"; } +.do-icon-share:before { content: "\e6ad"; } +.do-icon-tag:before { content: "\e6ae"; } +.do-icon-app:before { content: "\e6af"; } +.do-icon-app1:before { content: "\e6b0"; } +.do-icon-logout:before { content: "\e6b1"; } +.do-icon-menu-dot:before { content: "\e6b2"; } +.do-icon-trigon-up:before { content: "\e6b3"; } +.do-icon-trigon-down:before { content: "\e6b4"; } +.do-icon-loading:before { content: "\e6b5"; } +.do-icon-position:before { content: "\e6b6"; } +.do-icon-warn:before { content: "\e6b7"; } +.do-icon-bell:before { content: "\e6b8"; } +.do-icon-close:before { content: "\e6b9"; } +.do-icon-fire:before { content: "\e6ba"; } +.do-icon-user:before { content: "\e6bb"; } +.do-icon-icon-list:before { content: "\e6bc"; } +.do-icon-star:before { content: "\e6bd"; } +.do-icon-client:before { content: "\e6be"; } +.do-icon-maximize:before { content: "\e6bf"; } +.do-icon-star-full:before { content: "\e6c0"; } +.do-icon-camera:before { content: "\e6c1"; } +.do-icon-live:before { content: "\e6c2"; } +.do-icon-get:before { content: "\e6c3"; } +.do-icon-wrong:before { content: "\e6c4"; } \ No newline at end of file diff --git a/src/font/ui-font.eot b/src/font/ui-font.eot deleted file mode 100644 index fb01476..0000000 Binary files a/src/font/ui-font.eot and /dev/null differ diff --git a/src/font/ui-font.js b/src/font/ui-font.js deleted file mode 100644 index 95f34ca..0000000 --- a/src/font/ui-font.js +++ /dev/null @@ -1 +0,0 @@ -(function(window){var svgSprite='';var script=function(){var scripts=document.getElementsByTagName("script");return scripts[scripts.length-1]}();var shouldInjectCss=script.getAttribute("data-injectcss");var ready=function(fn){if(document.addEventListener){if(~["complete","loaded","interactive"].indexOf(document.readyState)){setTimeout(fn,0)}else{var loadFn=function(){document.removeEventListener("DOMContentLoaded",loadFn,false);fn()};document.addEventListener("DOMContentLoaded",loadFn,false)}}else if(document.attachEvent){IEContentLoaded(window,fn)}function IEContentLoaded(w,fn){var d=w.document,done=false,init=function(){if(!done){done=true;fn()}};var polling=function(){try{d.documentElement.doScroll("left")}catch(e){setTimeout(polling,50);return}init()};polling();d.onreadystatechange=function(){if(d.readyState=="complete"){d.onreadystatechange=null;init()}}}};var before=function(el,target){target.parentNode.insertBefore(el,target)};var prepend=function(el,target){if(target.firstChild){before(el,target.firstChild)}else{target.appendChild(el)}};function appendSvg(){var div,svg;div=document.createElement("div");div.innerHTML=svgSprite;svgSprite=null;svg=div.getElementsByTagName("svg")[0];if(svg){svg.setAttribute("aria-hidden","true");svg.style.position="absolute";svg.style.width=0;svg.style.height=0;svg.style.overflow="hidden";prepend(svg,document.body)}}if(shouldInjectCss&&!window.__iconfont__svg__cssinject__){window.__iconfont__svg__cssinject__=true;try{document.write("")}catch(e){console&&console.log(e)}}ready(appendSvg)})(window) \ No newline at end of file diff --git a/src/font/ui-font.ttf b/src/font/ui-font.ttf deleted file mode 100644 index 70e12c1..0000000 Binary files a/src/font/ui-font.ttf and /dev/null differ diff --git a/src/js/anot.js b/src/js/anot.js index 68a7593..8444c71 100644 --- a/src/js/anot.js +++ b/src/js/anot.js @@ -305,6 +305,244 @@ const _Anot = (function() { /*-----------------部分ES6的JS实现 start---------------*/ + // =============================== + // ========== Promise ============ + // =============================== + ;(function(nativePromise) { + function _yes(val) { + return val + } + + function _no(err) { + throw err + } + + function done(callback) { + return this.then(callback, _no) + } + + function fail(callback) { + return this.then(_yes, callback) + } + + function defer() { + var obj = {} + obj.promise = new _Promise(function(yes, no) { + obj.resolve = yes + obj.reject = no + }) + return obj + } + + //成功的回调 + function _resolve(obj, val) { + if (obj._state !== 'pending') { + return + } + + if (val && typeof val.then === 'function') { + var method = val instanceof _Promise ? '_then' : 'then' + val[method]( + function(v) { + _transmit(obj, v, true) + }, + function(v) { + _transmit(obj, v, false) + } + ) + } else { + _transmit(obj, val, true) + } + } + + //失败的回调 + function _reject(obj, val) { + if (obj._state !== 'pending') { + return + } + + _transmit(obj, val, false) + } + + // 改变Promise的_fired值,并保持用户传参,触发所有回调 + function _transmit(obj, val, isResolved) { + obj._fired = true + obj._val = val + obj._state = isResolved ? 'fulfilled' : 'rejected' + + fireCallback(obj, function() { + for (var i in obj.callback) { + obj._fire(obj.callback[i].yes, obj.callback[i].no) + } + }) + } + + function fireCallback(obj, callback) { + var isAsync = false + + if (typeof obj.async === 'boolean') { + isAsync = obj.async + } else { + isAsync = obj.async = true + } + + if (isAsync) { + setTimeout(callback, 0) + } else { + callback() + } + } + + function _some(bool, iterable) { + iterable = Array.isArray(iterable) ? iterable : [] + + var n = 0 + var res = [] + var end = false + + return new _Promise(function(yes, no) { + if (!iterable.length) no(res) + + function loop(obj, idx) { + obj.then( + function(val) { + if (!end) { + res[idx] = val + n++ + if (bool || n >= iterable.length) { + yes(bool ? val : res) + end = true + } + } + }, + function(val) { + end = true + no(val) + } + ) + } + + for (var i = 0, len = iterable.length; i < len; i++) { + loop(iterable[i], i) + } + }) + } + + //--------------------------- + var _Promise = function(callback) { + this.callback = [] + var _this = this + + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new') + } + + if (typeof callback !== 'function') { + throw new TypeError('Argument must be a function') + } + + callback( + function(val) { + _resolve(_this, val) + }, + function(val) { + _reject(_this, val) + } + ) + } + var self = { + _state: 1, + _fired: 1, + _val: 1, + callback: 1 + } + + _Promise.prototype = { + constructor: _Promise, + _state: 'pending', + _fired: false, + _fire: function(yes, no) { + if (this._state === 'rejected') { + if (typeof no === 'function') no(this._val) + else throw this._val + } else { + if (typeof yes === 'function') yes(this._val) + } + }, + _then: function(yes, no) { + if (this._fired) { + var _this = this + fireCallback(_this, function() { + _this._fire(yes, no) + }) + } else { + this.callback.push({ yes: yes, no: no }) + } + }, + then: function(yes, no) { + yes = typeof yes === 'function' ? yes : _yes + no = typeof no === 'function' ? no : _no + var _this = this + var next = new _Promise(function(resolve, reject) { + _this._then( + function(val) { + try { + val = yes(val) + } catch (err) { + return reject(err) + } + }, + function(val) { + try { + val = no(val) + } catch (err) { + return reject(err) + } + resolve(val) + } + ) + }) + for (var i in _this) { + if (!self[i]) next[i] = _this[i] + } + return next + }, + done: done, + catch: fail, + fail: fail + } + + _Promise.all = function(arr) { + return _some(false, arr) + } + + _Promise.race = function(arr) { + return _some(true, arr) + } + + _Promise.defer = defer + + _Promise.resolve = function(val) { + var obj = this.defer() + obj.resolve(val) + return obj.promise + } + + _Promise.reject = function(val) { + var obj = this.defer() + obj.reject(val) + return obj.promise + } + if (/native code/.test(nativePromise)) { + nativePromise.prototype.done = done + nativePromise.prototype.fail = fail + if (!nativePromise.defer) { + nativePromise.defer = defer + } + } + window.Promise = nativePromise || _Promise + })(window.Promise) + if (!Object.assign) { Object.defineProperty(Object, 'assign', { enumerable: false, @@ -529,6 +767,33 @@ const _Anot = (function() { /*-----------------部分ES6的JS实现 ending---------------*/ + function cacheStore(tpye, key, val) { + if (!window[tpye]) { + return log('该浏览器不支持本地储存' + tpye) + } + + if (this.type(key) === 'object') { + for (var i in key) { + window[tpye].setItem(i, key[i]) + } + return + } + switch (arguments.length) { + case 2: + return window[tpye].getItem(key) + default: + if ((this.type(val) == 'string' && val.trim() === '') || val === null) { + window[tpye].removeItem(key) + return + } + if (this.type(val) !== 'object' && this.type(val) !== 'array') { + window[tpye].setItem(key, val.toString()) + } else { + window[tpye].setItem(key, JSON.stringify(val)) + } + } + } + Anot.mix({ rword: rword, subscribers: subscribers, @@ -671,55 +936,32 @@ const _Anot = (function() { }, /** * [ls localStorage操作] - * @param {[type]} name [键名] + * @param {[type]} key [键名] * @param {[type]} val [键值,为空时删除] * @return */ - ls: function(name, val) { - if (!window.localStorage) { - return log('该浏览器不支持本地储存localStorage') - } - - if (this.type(name) === 'object') { - for (var i in name) { - localStorage.setItem(i, name[i]) - } - return - } - switch (arguments.length) { - case 1: - return localStorage.getItem(name) - default: - if ( - (this.type(val) == 'string' && val.trim() === '') || - val === null - ) { - localStorage.removeItem(name) - return - } - if (this.type(val) !== 'object' && this.type(val) !== 'array') { - localStorage.setItem(name, val.toString()) - } else { - localStorage.setItem(name, JSON.stringify(val)) - } - } + ls: function(key, val) { + return cacheStore('localStorage', key, val) + }, + ss: function(key, val) { + return cacheStore('sessionStorage', key, val) }, /** * [cookie cookie 操作 ] - * @param name [cookie名] - * @param value [cookie值] + * @param key [cookie名] + * @param val [cookie值] * @param {[json]} opt [有效期,域名,路径等] * @return {[boolean]} [读取时返回对应的值,写入时返回true] */ - cookie: function(name, value, opt) { + cookie: function(key, val, opt) { if (arguments.length > 1) { - if (!name) { + if (!key) { return } //设置默认的参数 opt = opt || {} - opt = this.mix( + opt = Object.assign( { expires: '', path: '/', @@ -729,9 +971,9 @@ const _Anot = (function() { opt ) - if (!value) { + if ((this.type(val) == 'string' && val.trim() === '') || val === null) { document.cookie = - encodeURIComponent(name) + + encodeURIComponent(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=' + opt.domain + '; path=' + @@ -755,9 +997,9 @@ const _Anot = (function() { } } document.cookie = - encodeURIComponent(name) + + encodeURIComponent(key) + '=' + - encodeURIComponent(value) + + encodeURIComponent(val) + opt.expires + '; domain=' + opt.domain + @@ -767,24 +1009,15 @@ const _Anot = (function() { opt.secure return true } else { - if (!name) { - var keys = document.cookie - .replace( - /((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, - '' - ) - .split(/\s*(?:\=[^;]*)?;\s*/) - for (var i = 0, len = keys.length; i < len; i++) { - keys[i] = decodeURIComponent(keys[i]) - } - return keys + if (!key) { + return document.cookie } return ( decodeURIComponent( document.cookie.replace( new RegExp( '(?:(?:^|.*;)\\s*' + - encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') + + encodeURIComponent(key).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$' ), '$1' @@ -1527,7 +1760,7 @@ const _Anot = (function() { $vmodel.$active = true $vmodel.mounted = mounted - if (old && old.$up) { + if (old && old.$up && old.$up.$children) { old.$up.$children.push($vmodel) } @@ -3467,6 +3700,19 @@ const _Anot = (function() { } } + function parseSlot(collections) { + var arr = aslice.call(collections, 0) + var obj = {} + arr.forEach(function(elem) { + var slot = elem.getAttribute('slot') + if (slot) { + elem.removeAttribute('slot') + obj[slot] = elem.outerHTML + } + }) + return obj + } + Anot.components = {} Anot.component = function(name, opts) { if (opts) { @@ -3531,17 +3777,21 @@ const _Anot = (function() { componentWillMount.call(vmodel) globalHooks.componentWillMount.call(null, vmodel) - if (!elem.content.firstElementChild) { - Anot.clearHTML(elem) - var html = render.call(vmodel) || '' + var slots = null - html = html.replace(/<\w+[^>]*>/g, function(m, s) { - return m.replace(/[\n\t\s]{1,}/g, ' ') - }) - - elem.innerHTML = html + if (elem.content.firstElementChild) { + slots = parseSlot(elem.content.children) } + Anot.clearHTML(elem) + var html = render.call(vmodel, slots) || '' + + html = html.replace(/<\w+[^>]*>/g, function(m, s) { + return m.replace(/[\n\t\s]{1,}/g, ' ') + }) + + elem.innerHTML = html + // 组件所使用的标签是temlate,所以必须要要用子元素替换掉 var child = elem.content.firstElementChild var nullComponent = DOC.createComment('empty component') diff --git a/src/js/anot.shim.js b/src/js/anot.shim.js index 32fd7f8..f255be4 100644 --- a/src/js/anot.shim.js +++ b/src/js/anot.shim.js @@ -320,6 +320,244 @@ /*-----------------部分ES6的JS实现 start---------------*/ + // =============================== + // ========== Promise ============ + // =============================== + ;(function(nativePromise) { + function _yes(val) { + return val + } + + function _no(err) { + throw err + } + + function done(callback) { + return this.then(callback, _no) + } + + function fail(callback) { + return this.then(_yes, callback) + } + + function defer() { + var obj = {} + obj.promise = new _Promise(function(yes, no) { + obj.resolve = yes + obj.reject = no + }) + return obj + } + + //成功的回调 + function _resolve(obj, val) { + if (obj._state !== 'pending') { + return + } + + if (val && typeof val.then === 'function') { + var method = val instanceof _Promise ? '_then' : 'then' + val[method]( + function(v) { + _transmit(obj, v, true) + }, + function(v) { + _transmit(obj, v, false) + } + ) + } else { + _transmit(obj, val, true) + } + } + + //失败的回调 + function _reject(obj, val) { + if (obj._state !== 'pending') { + return + } + + _transmit(obj, val, false) + } + + // 改变Promise的_fired值,并保持用户传参,触发所有回调 + function _transmit(obj, val, isResolved) { + obj._fired = true + obj._val = val + obj._state = isResolved ? 'fulfilled' : 'rejected' + + fireCallback(obj, function() { + for (var i in obj.callback) { + obj._fire(obj.callback[i].yes, obj.callback[i].no) + } + }) + } + + function fireCallback(obj, callback) { + var isAsync = false + + if (typeof obj.async === 'boolean') { + isAsync = obj.async + } else { + isAsync = obj.async = true + } + + if (isAsync) { + setTimeout(callback, 0) + } else { + callback() + } + } + + function _some(bool, iterable) { + iterable = Array.isArray(iterable) ? iterable : [] + + var n = 0 + var res = [] + var end = false + + return new _Promise(function(yes, no) { + if (!iterable.length) no(res) + + function loop(obj, idx) { + obj.then( + function(val) { + if (!end) { + res[idx] = val + n++ + if (bool || n >= iterable.length) { + yes(bool ? val : res) + end = true + } + } + }, + function(val) { + end = true + no(val) + } + ) + } + + for (var i = 0, len = iterable.length; i < len; i++) { + loop(iterable[i], i) + } + }) + } + + //--------------------------- + var _Promise = function(callback) { + this.callback = [] + var _this = this + + if (typeof this !== 'object') { + throw new TypeError('Promises must be constructed via new') + } + + if (typeof callback !== 'function') { + throw new TypeError('Argument must be a function') + } + + callback( + function(val) { + _resolve(_this, val) + }, + function(val) { + _reject(_this, val) + } + ) + } + var self = { + _state: 1, + _fired: 1, + _val: 1, + callback: 1 + } + + _Promise.prototype = { + constructor: _Promise, + _state: 'pending', + _fired: false, + _fire: function(yes, no) { + if (this._state === 'rejected') { + if (typeof no === 'function') no(this._val) + else throw this._val + } else { + if (typeof yes === 'function') yes(this._val) + } + }, + _then: function(yes, no) { + if (this._fired) { + var _this = this + fireCallback(_this, function() { + _this._fire(yes, no) + }) + } else { + this.callback.push({ yes: yes, no: no }) + } + }, + then: function(yes, no) { + yes = typeof yes === 'function' ? yes : _yes + no = typeof no === 'function' ? no : _no + var _this = this + var next = new _Promise(function(resolve, reject) { + _this._then( + function(val) { + try { + val = yes(val) + } catch (err) { + return reject(err) + } + }, + function(val) { + try { + val = no(val) + } catch (err) { + return reject(err) + } + resolve(val) + } + ) + }) + for (var i in _this) { + if (!self[i]) next[i] = _this[i] + } + return next + }, + done: done, + catch: fail, + fail: fail + } + + _Promise.all = function(arr) { + return _some(false, arr) + } + + _Promise.race = function(arr) { + return _some(true, arr) + } + + _Promise.defer = defer + + _Promise.resolve = function(val) { + var obj = this.defer() + obj.resolve(val) + return obj.promise + } + + _Promise.reject = function(val) { + var obj = this.defer() + obj.reject(val) + return obj.promise + } + if (/native code/.test(nativePromise)) { + nativePromise.prototype.done = done + nativePromise.prototype.fail = fail + if (!nativePromise.defer) { + nativePromise.defer = defer + } + } + window.Promise = nativePromise || _Promise + })(window.Promise) + if (!Object.assign) { Object.defineProperty(Object, 'assign', { enumerable: false, @@ -544,6 +782,33 @@ /*-----------------部分ES6的JS实现 ending---------------*/ + function cacheStore(tpye, key, val) { + if (!window[tpye]) { + return log('该浏览器不支持本地储存' + tpye) + } + + if (this.type(key) === 'object') { + for (var i in key) { + window[tpye].setItem(i, key[i]) + } + return + } + switch (arguments.length) { + case 2: + return window[tpye].getItem(key) + default: + if ((this.type(val) == 'string' && val.trim() === '') || val === null) { + window[tpye].removeItem(key) + return + } + if (this.type(val) !== 'object' && this.type(val) !== 'array') { + window[tpye].setItem(key, val.toString()) + } else { + window[tpye].setItem(key, JSON.stringify(val)) + } + } + } + Anot.mix({ rword: rword, subscribers: subscribers, @@ -686,55 +951,32 @@ }, /** * [ls localStorage操作] - * @param {[type]} name [键名] + * @param {[type]} key [键名] * @param {[type]} val [键值,为空时删除] * @return */ - ls: function(name, val) { - if (!window.localStorage) { - return log('该浏览器不支持本地储存localStorage') - } - - if (this.type(name) === 'object') { - for (var i in name) { - localStorage.setItem(i, name[i]) - } - return - } - switch (arguments.length) { - case 1: - return localStorage.getItem(name) - default: - if ( - (this.type(val) == 'string' && val.trim() === '') || - val === null - ) { - localStorage.removeItem(name) - return - } - if (this.type(val) !== 'object' && this.type(val) !== 'array') { - localStorage.setItem(name, val.toString()) - } else { - localStorage.setItem(name, JSON.stringify(val)) - } - } + ls: function(key, val) { + return cacheStore('localStorage', key, val) + }, + ss: function(key, val) { + return cacheStore('sessionStorage', key, val) }, /** * [cookie cookie 操作 ] - * @param name [cookie名] - * @param value [cookie值] + * @param key [cookie名] + * @param val [cookie值] * @param {[json]} opt [有效期,域名,路径等] * @return {[boolean]} [读取时返回对应的值,写入时返回true] */ - cookie: function(name, value, opt) { + cookie: function(key, val, opt) { if (arguments.length > 1) { - if (!name) { + if (!key) { return } //设置默认的参数 opt = opt || {} - opt = this.mix( + opt = Object.assign( { expires: '', path: '/', @@ -744,9 +986,9 @@ opt ) - if (!value) { + if ((this.type(val) == 'string' && val.trim() === '') || val === null) { document.cookie = - encodeURIComponent(name) + + encodeURIComponent(key) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=' + opt.domain + '; path=' + @@ -770,9 +1012,9 @@ } } document.cookie = - encodeURIComponent(name) + + encodeURIComponent(key) + '=' + - encodeURIComponent(value) + + encodeURIComponent(val) + opt.expires + '; domain=' + opt.domain + @@ -782,24 +1024,15 @@ opt.secure return true } else { - if (!name) { - var keys = document.cookie - .replace( - /((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, - '' - ) - .split(/\s*(?:\=[^;]*)?;\s*/) - for (var i = 0, len = keys.length; i < len; i++) { - keys[i] = decodeURIComponent(keys[i]) - } - return keys + if (!key) { + return document.cookie } return ( decodeURIComponent( document.cookie.replace( new RegExp( '(?:(?:^|.*;)\\s*' + - encodeURIComponent(name).replace(/[\-\.\+\*]/g, '\\$&') + + encodeURIComponent(key).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$' ), '$1' @@ -1542,7 +1775,7 @@ $vmodel.$active = true $vmodel.mounted = mounted - if (old && old.$up) { + if (old && old.$up && old.$up.$children) { old.$up.$children.push($vmodel) } @@ -3482,6 +3715,19 @@ } } + function parseSlot(collections) { + var arr = aslice.call(collections, 0) + var obj = {} + arr.forEach(function(elem) { + var slot = elem.getAttribute('slot') + if (slot) { + elem.removeAttribute('slot') + obj[slot] = elem.outerHTML + } + }) + return obj + } + Anot.components = {} Anot.component = function(name, opts) { if (opts) { @@ -3546,17 +3792,21 @@ componentWillMount.call(vmodel) globalHooks.componentWillMount.call(null, vmodel) - if (!elem.content.firstElementChild) { - Anot.clearHTML(elem) - var html = render.call(vmodel) || '' + var slots = null - html = html.replace(/<\w+[^>]*>/g, function(m, s) { - return m.replace(/[\n\t\s]{1,}/g, ' ') - }) - - elem.innerHTML = html + if (elem.content.firstElementChild) { + slots = parseSlot(elem.content.children) } + Anot.clearHTML(elem) + var html = render.call(vmodel, slots) || '' + + html = html.replace(/<\w+[^>]*>/g, function(m, s) { + return m.replace(/[\n\t\s]{1,}/g, ' ') + }) + + elem.innerHTML = html + // 组件所使用的标签是temlate,所以必须要要用子元素替换掉 var child = elem.content.firstElementChild var nullComponent = DOC.createComment('empty component') @@ -5811,7 +6061,9 @@ } oDate = new Date(stamp) - if (oDate + '' === 'Invalid Date') return 'Invalid Date' + if (oDate + '' === 'Invalid Date') { + return 'Invalid Date' + } } else { oDate = stamp } @@ -5867,9 +6119,7 @@ var ext = '.js' //默认拓展名 var res = 'js' // 默认资源类型 var suffix = ['.js', '.css'] - var cssfix = /\.(scss|sass|less)$/ name = name.replace(/\.[a-z0-9]+$/g, function(match) { - match = match.replace(cssfix, '.css') ext = match res = suffix.indexOf(match) > -1 ? match.slice(1) : 'text' return '' diff --git a/src/js/pager/index.js b/src/js/pager/index.js index 594fa1f..92e29cb 100644 --- a/src/js/pager/index.js +++ b/src/js/pager/index.js @@ -51,22 +51,22 @@ function update(currPage, vm) { } const tmpls = { - home: ``, - end: ``, - prev: ``, - next: `