From ef7fa7cee778a63c290eb54689231a175fe8aeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 21 Dec 2017 04:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dattr=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/anot.shim.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/js/anot.shim.js b/src/js/anot.shim.js index 2773ec2..ae59b6e 100644 --- a/src/js/anot.shim.js +++ b/src/js/anot.shim.js @@ -3080,11 +3080,6 @@ if (events[type]) { param = type type = 'on' - } else if (obsoleteAttrs[type]) { - param = type - type = 'attr' - name = ':' + type + '-' + param - log('warning!请改用' + name + '代替' + attr.name + '!') } if (directives[type]) { var newValue = value.replace(roneTime, '') @@ -3232,14 +3227,32 @@ if (vmodels.length) { attrs.forEach(function(attr, i) { if (/^:/.test(attr.name)) { - var name = attr.name.replace(':', '') + var name = attr.name.match(rmsAttr)[1] var value = null - if (Anot.directives[name]) { + if (!name || Anot.directives[name]) { return } try { value = parseExpr(attr.value, vmodels, {}).apply(0, vmodels) elem.removeAttribute(attr.name) + if (!value) { + return + } + if ( + newVmodel.props[name] && + newVmodel.props[name].type === 'PropsTypes' + ) { + if (newVmodel.props[name].check(value)) { + newVmodel.props[name] = value + } else { + Anot.error( + 'props「' + name + '」类型错误!' + value, + TypeError + ) + } + } else { + newVmodel.props[name] = value + } } catch (error) { log( 'Props parse faild on (%s[class=%s]),', @@ -3249,21 +3262,6 @@ error + '' ) } - if (!value) { - return - } - if ( - newVmodel.props[name] && - newVmodel.props[name].type === 'PropsTypes' - ) { - if (newVmodel.props[name].check(value)) { - newVmodel.props[name] = value - } else { - Anot.error('props「' + name + '」类型错误!' + value, TypeError) - } - } else { - newVmodel.props[name] = value - } } }) }