From 8b21f0a800863a0256c2b756b70f875882f4e5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Fri, 14 Aug 2020 18:46:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=A4=A7=E6=B3=A2=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/directives/class.hover.active.js | 5 +- src/directives/css.js | 4 +- src/directives/duplex/updateDataActions.js | 2 +- src/directives/for.js | 8 +- src/directives/if.js | 2 +- src/directives/on.js | 2 +- src/directives/rules.js | 2 +- src/directives/text.js | 2 +- src/directives/validate.js | 9 +- src/dom/class/modern.js | 2 +- src/dom/css/share.js | 6 +- src/dom/event/modern.js | 2 +- src/dom/event/share.js | 6 +- src/effect/index.js | 12 +- src/filters/array.js | 11 +- src/filters/date.js | 310 +++++++-------------- src/filters/event.js | 14 +- src/filters/index.js | 37 +-- src/filters/number.js | 46 +-- src/filters/{sanitize.js => xss.js} | 2 +- src/gesture/tap.js | 3 +- src/parser/index.js | 8 +- src/parser/interpolate.js | 4 +- src/renders/domRender.js | 8 +- src/seed/core.js | 150 +++------- src/seed/directive.js | 2 +- src/seed/lang.js | 11 +- src/vdom/VElement.modern.js | 2 +- src/vdom/VText.js | 4 +- src/vmodel/Action.js | 2 +- src/vmodel/Computed.js | 4 +- src/vmodel/Mutation.js | 2 +- src/vmodel/proxy.js | 285 +++++++++---------- src/vmodel/share.js | 28 +- src/vmodel/transaction.js | 16 +- src/vtree/validateDOMNesting.js | 4 +- 36 files changed, 386 insertions(+), 631 deletions(-) rename src/filters/{sanitize.js => xss.js} (97%) diff --git a/src/directives/class.hover.active.js b/src/directives/class.hover.active.js index 1b54aa8..05259f1 100644 --- a/src/directives/class.hover.active.js +++ b/src/directives/class.hover.active.js @@ -2,10 +2,9 @@ //http://www.cnblogs.com/rubylouvre/archive/2012/12/17/2818540.html import { Anot, directives, getLongID as markID } from '../seed/core' -function classNames() { +function classNames(...args) { var classes = [] - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i] + for (let arg of args) { var argType = typeof arg if (argType === 'string' || argType === 'number' || arg === true) { classes.push(arg) diff --git a/src/directives/css.js b/src/directives/css.js index a6f28b9..5eac88d 100644 --- a/src/directives/css.js +++ b/src/directives/css.js @@ -8,11 +8,11 @@ var cssDir = Anot.directive('css', { //转换成对象 var b = {} newVal.forEach(function(el) { - el && Anot.shadowCopy(b, el) + el && Object.assign(b, el) }) newVal = b if (!arrayWarn[this.type]) { - Anot.warn('ms-' + this.type + '指令的值不建议使用数组形式了!') + console.warn('ms-' + this.type + '指令的值不建议使用数组形式了!') arrayWarn[this.type] = 1 } } diff --git a/src/directives/duplex/updateDataActions.js b/src/directives/duplex/updateDataActions.js index fa1507c..2093eb7 100644 --- a/src/directives/duplex/updateDataActions.js +++ b/src/directives/duplex/updateDataActions.js @@ -36,7 +36,7 @@ export var updateDataActions = { var field = this var array = field.value if (!Array.isArray(array)) { - Anot.warn('ms-duplex应用于checkbox上要对应一个数组') + console.warn('ms-duplex应用于checkbox上要对应一个数组') array = [array] } var method = field.dom.checked ? 'ensure' : 'remove' diff --git a/src/directives/for.js b/src/directives/for.js index c6176c9..0ef6082 100644 --- a/src/directives/for.js +++ b/src/directives/for.js @@ -19,7 +19,7 @@ Anot.directive('for', { str = str.replace(rforAs, function(a, b) { /* istanbul ignore if */ if (!rident.test(b) || rinvalid.test(b)) { - Anot.error( + console.error( 'alias ' + b + ' is invalid --- must be a valid JS identifier which is not a reserved name.' @@ -226,11 +226,7 @@ function updateItemVm(vm, top) { } function resetVM(vm, a, b) { - if (Anot.config.inProxyMode) { - vm.$accessors[a].value = NaN - } else { - vm.$accessors[a].set(NaN) - } + vm.$accessors[a].value = NaN } function updateList(instance) { diff --git a/src/directives/if.js b/src/directives/if.js index 8652f19..6c3dd01 100644 --- a/src/directives/if.js +++ b/src/directives/if.js @@ -55,6 +55,6 @@ function continueScan(instance, vdom) { instance.fragment, instance.vm )) - Anot.shadowCopy(vdom, innerRender.root) + Object.assign(vdom, innerRender.root) delete vdom.nodeValue } diff --git a/src/directives/on.js b/src/directives/on.js index 5140ddf..addc003 100644 --- a/src/directives/on.js +++ b/src/directives/on.js @@ -31,7 +31,7 @@ Anot.directive('on', { '\tvar __vmodel__ = this;', '\t' + filters, '\treturn ' + body, - '}catch(e){Anot.log(e, "in on dir")}' + '}catch(e){console.log(e, "in on dir")}' ].filter(function(el) { return /\S/.test(el) }) diff --git a/src/directives/rules.js b/src/directives/rules.js index 93fbb06..291b5f2 100644 --- a/src/directives/rules.js +++ b/src/directives/rules.js @@ -33,7 +33,7 @@ function isCorrectDate(value) { return false } //https://github.com/adform/validator.js/blob/master/validator.js -Anot.shadowCopy(Anot.validators, { +Object.assign(Anot.validators, { pattern: { message: '必须匹配{{pattern}}这样的格式', get: function(value, field, next) { diff --git a/src/directives/text.js b/src/directives/text.js index 9001f32..a994443 100644 --- a/src/directives/text.js +++ b/src/directives/text.js @@ -5,7 +5,7 @@ Anot.directive('text', { init: function() { var node = this.node if (node.isVoidTag) { - Anot.error('自闭合元素不能使用ms-text') + console.error('自闭合元素不能使用ms-text') } var child = { nodeName: '#text', nodeValue: this.getValue() } node.children.splice(0, node.children.length, child) diff --git a/src/directives/validate.js b/src/directives/validate.js index b83cddc..7ceb430 100644 --- a/src/directives/validate.js +++ b/src/directives/validate.js @@ -44,7 +44,7 @@ var valiDir = Anot.directive('validate', { var fn = (vmValidator.onManual = onManual.bind(vmValidator)) validator.onManual = fn } catch (e) { - Anot.warn( + console.warn( '要想使用onManual方法,必须在validate对象预定义一个空的onManual函数' ) } @@ -94,12 +94,7 @@ var valiDir = Anot.directive('validate', { var value = field.value var elem = field.dom /* istanbul ignore if */ - if (typeof Promise !== 'function') { - //Anot-promise不支持phantomjs - Anot.warn( - '浏览器不支持原生Promise,请下载并