This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化attr指令并

old
宇天 2018-06-23 02:43:00 +08:00
parent e9ca20f621
commit 9f9456618e
4 changed files with 32 additions and 24 deletions

View File

@ -3361,6 +3361,8 @@ const _Anot = (function() {
function getOptionsFromTag(elem, vmodels) { function getOptionsFromTag(elem, vmodels) {
var attributes = aslice.call(elem.attributes, 0) var attributes = aslice.call(elem.attributes, 0)
var ret = {} var ret = {}
var vm = vmodels[0] || {}
for (var i = 0, attr; (attr = attributes[i++]); ) { for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name var name = attr.name
if ( if (
@ -3376,9 +3378,7 @@ const _Anot = (function() {
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
var vm = vmodels[0]
if ( if (
vm &&
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'
) { ) {
@ -4077,7 +4077,7 @@ const _Anot = (function() {
var outer = (binding.includeReplace = !!Anot(elem).data( var outer = (binding.includeReplace = !!Anot(elem).data(
'includeReplace' 'includeReplace'
)) ))
if (Anot(elem).data('includeCache')) { if (Anot(elem).data('cache')) {
binding.templateCache = {} binding.templateCache = {}
} }
binding.start = DOC.createComment(':include') binding.start = DOC.createComment(':include')
@ -4098,15 +4098,17 @@ const _Anot = (function() {
var obj = {} var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
val = toJson(val)
if (this.param) { if (this.param) {
if (typeof val === 'object' && val !== null) { if (typeof val === 'object' && val !== null) {
if (Array.isArray(val)) { if (Array.isArray(val)) {
obj[this.param] = val.$model || val obj[this.param] = val
} else { } else {
if (Date.isDate(val)) { if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj[this.param] = val.$model || val obj[this.param] = val
} }
} }
} else { } else {
@ -4120,7 +4122,7 @@ const _Anot = (function() {
return return
} }
obj = val.$model || val obj = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -3376,6 +3376,8 @@
function getOptionsFromTag(elem, vmodels) { function getOptionsFromTag(elem, vmodels) {
var attributes = aslice.call(elem.attributes, 0) var attributes = aslice.call(elem.attributes, 0)
var ret = {} var ret = {}
var vm = vmodels[0] || {}
for (var i = 0, attr; (attr = attributes[i++]); ) { for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name var name = attr.name
if ( if (
@ -3391,9 +3393,7 @@
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
var vm = vmodels[0]
if ( if (
vm &&
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'
) { ) {
@ -4092,7 +4092,7 @@
var outer = (binding.includeReplace = !!Anot(elem).data( var outer = (binding.includeReplace = !!Anot(elem).data(
'includeReplace' 'includeReplace'
)) ))
if (Anot(elem).data('includeCache')) { if (Anot(elem).data('cache')) {
binding.templateCache = {} binding.templateCache = {}
} }
binding.start = DOC.createComment(':include') binding.start = DOC.createComment(':include')
@ -4113,15 +4113,17 @@
var obj = {} var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
val = toJson(val)
if (this.param) { if (this.param) {
if (typeof val === 'object' && val !== null) { if (typeof val === 'object' && val !== null) {
if (Array.isArray(val)) { if (Array.isArray(val)) {
obj[this.param] = val.$model || val obj[this.param] = val
} else { } else {
if (Date.isDate(val)) { if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj[this.param] = val.$model || val obj[this.param] = val
} }
} }
} else { } else {
@ -4135,7 +4137,7 @@
return return
} }
obj = val.$model || val obj = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -3361,6 +3361,8 @@ const _Anot = (function() {
function getOptionsFromTag(elem, vmodels) { function getOptionsFromTag(elem, vmodels) {
var attributes = aslice.call(elem.attributes, 0) var attributes = aslice.call(elem.attributes, 0)
var ret = {} var ret = {}
var vm = vmodels[0] || {}
for (var i = 0, attr; (attr = attributes[i++]); ) { for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name var name = attr.name
if ( if (
@ -3376,9 +3378,7 @@ const _Anot = (function() {
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
var vm = vmodels[0]
if ( if (
vm &&
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'
) { ) {
@ -4077,7 +4077,7 @@ const _Anot = (function() {
var outer = (binding.includeReplace = !!Anot(elem).data( var outer = (binding.includeReplace = !!Anot(elem).data(
'includeReplace' 'includeReplace'
)) ))
if (Anot(elem).data('includeCache')) { if (Anot(elem).data('cache')) {
binding.templateCache = {} binding.templateCache = {}
} }
binding.start = DOC.createComment(':include') binding.start = DOC.createComment(':include')
@ -4098,15 +4098,17 @@ const _Anot = (function() {
var obj = {} var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
val = toJson(val)
if (this.param) { if (this.param) {
if (typeof val === 'object' && val !== null) { if (typeof val === 'object' && val !== null) {
if (Array.isArray(val)) { if (Array.isArray(val)) {
obj[this.param] = val.$model || val obj[this.param] = val
} else { } else {
if (Date.isDate(val)) { if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj[this.param] = val.$model || val obj[this.param] = val
} }
} }
} else { } else {
@ -4120,7 +4122,7 @@ const _Anot = (function() {
return return
} }
obj = val.$model || val obj = val
} }
for (var i in obj) { for (var i in obj) {

View File

@ -3376,6 +3376,8 @@
function getOptionsFromTag(elem, vmodels) { function getOptionsFromTag(elem, vmodels) {
var attributes = aslice.call(elem.attributes, 0) var attributes = aslice.call(elem.attributes, 0)
var ret = {} var ret = {}
var vm = vmodels[0] || {}
for (var i = 0, attr; (attr = attributes[i++]); ) { for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name var name = attr.name
if ( if (
@ -3391,9 +3393,7 @@
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
var vm = vmodels[0]
if ( if (
vm &&
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'
) { ) {
@ -4092,7 +4092,7 @@
var outer = (binding.includeReplace = !!Anot(elem).data( var outer = (binding.includeReplace = !!Anot(elem).data(
'includeReplace' 'includeReplace'
)) ))
if (Anot(elem).data('includeCache')) { if (Anot(elem).data('cache')) {
binding.templateCache = {} binding.templateCache = {}
} }
binding.start = DOC.createComment(':include') binding.start = DOC.createComment(':include')
@ -4113,15 +4113,17 @@
var obj = {} var obj = {}
var vm = this.vmodels[0] var vm = this.vmodels[0]
val = toJson(val)
if (this.param) { if (this.param) {
if (typeof val === 'object' && val !== null) { if (typeof val === 'object' && val !== null) {
if (Array.isArray(val)) { if (Array.isArray(val)) {
obj[this.param] = val.$model || val obj[this.param] = val
} else { } else {
if (Date.isDate(val)) { if (Date.isDate(val)) {
obj[this.param] = val.toUTCString() obj[this.param] = val.toUTCString()
} else { } else {
obj[this.param] = val.$model || val obj[this.param] = val
} }
} }
} else { } else {
@ -4135,7 +4137,7 @@
return return
} }
obj = val.$model || val obj = val
} }
for (var i in obj) { for (var i in obj) {