parent
d2e32f4067
commit
ab03d4a35a
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "anot",
|
"name": "anot",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"description": "Anot - 迷你mvvm框架",
|
"description": "Anot - 迷你mvvm框架",
|
||||||
"main": "dist/anot.js",
|
"main": "dist/anot.js",
|
||||||
"files": ["dist"],
|
"files": ["dist"],
|
||||||
|
|
|
@ -56,7 +56,7 @@ var events = oneObject(
|
||||||
'animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit'
|
'animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit'
|
||||||
)
|
)
|
||||||
var obsoleteAttrs = oneObject(
|
var obsoleteAttrs = oneObject(
|
||||||
'value,title,alt,checked,selected,disabled,readonly,enabled,href,src'
|
'value,title,alt,checked,selected,disabled,readonly,loading,enabled,href,src'
|
||||||
)
|
)
|
||||||
function bindingSorter(a, b) {
|
function bindingSorter(a, b) {
|
||||||
return a.priority - b.priority
|
return a.priority - b.priority
|
||||||
|
@ -85,8 +85,12 @@ function scanAttr(elem, vmodels, match) {
|
||||||
var param = match[2] || ''
|
var param = match[2] || ''
|
||||||
var eparam = match[3] || '' // 事件绑定的简写
|
var eparam = match[3] || '' // 事件绑定的简写
|
||||||
var value = attr.value
|
var value = attr.value
|
||||||
if (events[type] || events[eparam]) {
|
if (obsoleteAttrs[type]) {
|
||||||
param = type || eparam
|
param = type
|
||||||
|
type = 'attr'
|
||||||
|
}
|
||||||
|
if (eparam) {
|
||||||
|
param = eparam
|
||||||
type = 'on'
|
type = 'on'
|
||||||
}
|
}
|
||||||
if (directives[type]) {
|
if (directives[type]) {
|
||||||
|
|
|
@ -86,22 +86,30 @@ var attrDir = Anot.directive('attr', {
|
||||||
if (i === 'href' || i === 'src') {
|
if (i === 'href' || i === 'src') {
|
||||||
elem[i] = obj[i]
|
elem[i] = obj[i]
|
||||||
} else {
|
} else {
|
||||||
|
// 修正这些值的显示
|
||||||
if (obj[i] === false || obj[i] === null || obj[i] === undefined) {
|
if (obj[i] === false || obj[i] === null || obj[i] === undefined) {
|
||||||
obj[i] = ''
|
obj[i] = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof elem[boolMap[i]] === 'boolean') {
|
if (
|
||||||
|
typeof elem[i] === 'boolean' ||
|
||||||
|
typeof elem[boolMap[i]] === 'boolean'
|
||||||
|
) {
|
||||||
|
var k = i
|
||||||
|
if (boolMap[i] && k !== boolMap[i]) {
|
||||||
|
k = boolMap[i]
|
||||||
|
}
|
||||||
//布尔属性必须使用el.xxx = true|false方式设值
|
//布尔属性必须使用el.xxx = true|false方式设值
|
||||||
obj[i] = !!obj[i]
|
obj[i] = !!obj[i]
|
||||||
elem[boolMap[i]] = obj[i]
|
elem[k] = obj[i]
|
||||||
|
|
||||||
if (!obj[i]) {
|
if (!obj[i]) {
|
||||||
elem.removeAttribute(boolMap[i])
|
elem.removeAttribute(k)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy
|
//SVG只能使用setAttribute(xxx, yyy), HTML的固有属性必须elem.xxx = yyy
|
||||||
var isInnate = rsvg.test(elem) ? false : i in elem.cloneNode(false)
|
var isInnate = rsvg.test(elem) ? false : i in elem.cloneNode(false)
|
||||||
if (isInnate) {
|
if (isInnate) {
|
||||||
elem[i] = obj[i]
|
elem[i] = obj[i]
|
||||||
|
|
Reference in New Issue