修复svg的支持
parent
f795667b5b
commit
ccfd33529c
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "anot",
|
"name": "anot",
|
||||||
"version": "2.2.1",
|
"version": "2.2.2",
|
||||||
"description": "Anot - 迷你mvvm框架",
|
"description": "Anot - 迷你mvvm框架",
|
||||||
"main": "dist/anot.js",
|
"main": "dist/anot.js",
|
||||||
"files": ["dist"],
|
"files": ["dist"],
|
||||||
|
|
|
@ -50,7 +50,7 @@ function executeBindings(bindings, vmodels) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var roneTime = /^\s*::/
|
var roneTime = /^\s*::/
|
||||||
var rmsAttr = /:(\w+)-?(.*)|@(.*)/
|
var rmsAttr = /^:(\w+)-?(.*)|@(.*)/
|
||||||
|
|
||||||
var events = oneObject(
|
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'
|
||||||
|
@ -372,6 +372,8 @@ function scanText(textNode, vmodels, index) {
|
||||||
anotFragment.appendChild(node)
|
anotFragment.appendChild(node)
|
||||||
}
|
}
|
||||||
textNode.parentNode.replaceChild(anotFragment, textNode)
|
textNode.parentNode.replaceChild(anotFragment, textNode)
|
||||||
if (bindings.length) executeBindings(bindings, vmodels)
|
if (bindings.length) {
|
||||||
|
executeBindings(bindings, vmodels)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ var attrDir = Anot.directive('attr', {
|
||||||
update: function(val) {
|
update: function(val) {
|
||||||
var elem = this.element
|
var elem = this.element
|
||||||
var obj = {}
|
var obj = {}
|
||||||
|
var isSVG = rsvg.test(elem)
|
||||||
|
|
||||||
val = toJson(val)
|
val = toJson(val)
|
||||||
|
|
||||||
|
@ -83,9 +84,6 @@ var attrDir = Anot.directive('attr', {
|
||||||
elem.style.cssText = obj[i]
|
elem.style.cssText = obj[i]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (i === 'href' || i === 'src') {
|
|
||||||
elem[i] = obj[i]
|
|
||||||
} 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] = ''
|
||||||
|
@ -110,7 +108,7 @@ var attrDir = Anot.directive('attr', {
|
||||||
}
|
}
|
||||||
|
|
||||||
//SVG只能使用setAttribute(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 = isSVG ? false : i in elem.cloneNode(false)
|
||||||
if (isInnate) {
|
if (isInnate) {
|
||||||
elem[i] = obj[i]
|
elem[i] = obj[i]
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,5 +121,4 @@ var attrDir = Anot.directive('attr', {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
Reference in New Issue