From 353355dbf142762573bc23a0c807033946b79f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 26 Aug 2019 17:53:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BD=AC=E8=AF=91=E8=84=9A?= =?UTF-8?q?=E6=9C=AC;=E7=AE=80=E5=8C=96=E7=BB=84=E4=BB=B6=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.dev.js | 5 +- build.prod.js | 5 +- src/avatar/index.wc | 5 +- src/badge/index.wc | 5 +- src/form/button.wc | 9 +- src/form/cascader.wc | 380 ------------------------------------------- src/form/checkbox.wc | 9 +- src/form/input.wc | 9 +- src/form/progress.wc | 6 +- src/form/radio.wc | 31 ++-- src/form/select.wc | 9 +- src/form/switch.wc | 34 ++-- src/icon.js | 34 ---- src/icon/index.wc | 2 +- src/layer/next.wc | 6 +- src/pager/index.js | 254 ----------------------------- src/pager/index.wc | 6 +- src/picker/date.wc | 9 +- 18 files changed, 52 insertions(+), 766 deletions(-) delete mode 100644 src/icon.js delete mode 100644 src/pager/index.js diff --git a/build.dev.js b/build.dev.js index 6eca096..4a90832 100644 --- a/build.dev.js +++ b/build.dev.js @@ -112,7 +112,10 @@ function mkWCFile({ style, html, js }) { ) .replace('mounted()', 'connectedCallback()') .replace('unmount()', 'disconnectedCallback()') - .replace(/watch\(([\w\s,]*?)\)/, 'attributeChangedCallback($1)') + .replace( + 'watch() {', + 'attributeChangedCallback(name, old, val) {\nif (old === val) {return}' + ) .replace('adopted()', 'adoptedCallback()') return `/** diff --git a/build.prod.js b/build.prod.js index eafd74c..4d2a8da 100644 --- a/build.prod.js +++ b/build.prod.js @@ -119,7 +119,10 @@ function mkWCFile({ style, html, js }) { ) .replace('mounted()', 'connectedCallback()') .replace('unmount()', 'disconnectedCallback()') - .replace(/watch\(([\w\s,]*?)\)/, 'attributeChangedCallback($1)') + .replace( + 'watch() {', + 'attributeChangedCallback(name, old, val) {\nif (old === val) {return}' + ) .replace('adopted()', 'adoptedCallback()') let res = uglify.minify(js) diff --git a/src/avatar/index.wc b/src/avatar/index.wc index 59100cc..8553d0c 100644 --- a/src/avatar/index.wc +++ b/src/avatar/index.wc @@ -176,10 +176,7 @@ export default class Avatar { this.textContent = text } - watch(name, old, val) { - if (old === val) { - return - } + watch() { switch (name) { case 'src': this.removeAttribute('hash') diff --git a/src/badge/index.wc b/src/badge/index.wc index 0daef5b..87727ca 100644 --- a/src/badge/index.wc +++ b/src/badge/index.wc @@ -64,10 +64,7 @@ export default class Badge { this.__DOT__ = this.root.lastElementChild } - watch(name, old, val) { - if (old === val) { - return - } + watch() { switch (name) { case 'label': var num = Number(val) diff --git a/src/form/button.wc b/src/form/button.wc index eb69102..4690d06 100644 --- a/src/form/button.wc +++ b/src/form/button.wc @@ -313,10 +313,7 @@ export default class Button { this.__BTN__.removeEventListener('click', this._handleClick) } - watch(name, old, val) { - if (old === val) { - return - } + watch() { switch (name) { case 'icon': this.props.icon = val @@ -342,9 +339,7 @@ export default class Button { case 'loading': case 'disabled': - if (val === '') { - this[name] = true - } + this[name] = true break } } diff --git a/src/form/cascader.wc b/src/form/cascader.wc index d24bd57..e69de29 100644 --- a/src/form/cascader.wc +++ b/src/form/cascader.wc @@ -1,380 +0,0 @@ - - - - - diff --git a/src/form/checkbox.wc b/src/form/checkbox.wc index 00ffb62..03979de 100644 --- a/src/form/checkbox.wc +++ b/src/form/checkbox.wc @@ -220,10 +220,7 @@ export default class Checkbox { ) } - watch(name, old, val) { - if (old === val) { - return - } + watch() { switch (name) { case 'label': case 'color': @@ -232,9 +229,7 @@ export default class Checkbox { case 'checked': case 'disabled': - if (val === '') { - this[name] = true - } + this[name] = true break } } diff --git a/src/form/input.wc b/src/form/input.wc index 5a8a454..0ff8cf0 100644 --- a/src/form/input.wc +++ b/src/form/input.wc @@ -480,10 +480,7 @@ export default class Input { unbind(this.__LIST__, 'click', this._handleSelect) } - watch(name, old, val) { - if (old === val) { - return - } + watch() { switch (name) { case 'icon': this.props.icon = val @@ -525,9 +522,7 @@ export default class Input { case 'readonly': case 'disabled': - if (val === '') { - this[name] = true - } + this[name] = true break } } diff --git a/src/form/progress.wc b/src/form/progress.wc index 62d3640..f2666bd 100644 --- a/src/form/progress.wc +++ b/src/form/progress.wc @@ -90,11 +90,7 @@ export default class Progress { this.calculate() } - watch(name, old, val) { - if (old === val) { - return - } - + watch() { switch (name) { case max: var max = +val diff --git a/src/form/radio.wc b/src/form/radio.wc index ba5aa6d..dd1836a 100644 --- a/src/form/radio.wc +++ b/src/form/radio.wc @@ -153,6 +153,8 @@