Skip to content

Commit 84cf6f2

Browse files
committed
fix visible bug
1 parent 6229939 commit 84cf6f2

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

avalon.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@
784784
}
785785
}
786786
};
787-
function updateViewModel(a, b, isArray) {
787+
function updateViewModel(a, b, isArray,c) {
788788
if (isArray) {
789789
var an = a.length,
790790
bn = b.length;
@@ -801,6 +801,7 @@
801801
for (var i in b) {
802802
if (b.hasOwnProperty(i) && a.hasOwnProperty(i) && i !== "$id") {
803803
a[i] = b[i];
804+
c[i] = b[i];
804805
}
805806
}
806807
}
@@ -1475,8 +1476,11 @@
14751476
},
14761477
//控制元素显示或隐藏
14771478
"visible": function(data, scopes) {
1478-
watchView(data.value, scopes, data, function(val, elem) {
1479-
elem.style.display = val ? parseDisplay(elem.tagName) : "none";
1479+
var elem = data.element;
1480+
var display = avalon(elem).css("display");
1481+
display = display === "none" ? parseDisplay(elem.tagName) : display;
1482+
watchView(data.value, scopes, data, function(val) {
1483+
elem.style.display = val ? display : "none";
14801484
});
14811485
},
14821486
//这是一个字符串属性绑定的范本, 方便你在title, alt, src, href添加插值表达式
@@ -1858,13 +1862,9 @@
18581862
"sort,reverse".replace(rword, function(method) {
18591863
collection[method] = function() {
18601864
var ret = list[method].apply(list, arguments);
1861-
for(var i = 0, n = list.length; i < n ; i++){
1862-
var el = list[i];
1863-
collection.set(i, el);
1865+
for(var i = 0; i < ret.length; i++){
1866+
var el = ret[i];
18641867
}
1865-
// ret.forEach(function(el, i) {
1866-
// collection.set(i, el);
1867-
//});
18681868
return this;
18691869
};
18701870
});
@@ -1898,9 +1898,10 @@
18981898
if (val.$json) {
18991899
val = val.$json;
19001900
}
1901-
updateViewModel(this[index], val, Array.isArray(val));
1901+
updateViewModel(this[index], val, Array.isArray(val), list[index]);
19021902
} else if (this[index] !== val) {
19031903
this[index] = val;
1904+
19041905
model && model.$fire(prop + ".changed");
19051906
notifySubscribers(this, "set", arguments);
19061907
}
@@ -2435,4 +2436,4 @@
24352436
//2013.5.22 0.6.3 fix getValueFunction bug; fix avalon.bind return false bug;fix ms-css bug
24362437
//2013.5.25 0.7 添加template绑定, 优化渲染速度,插入与移除节点的操作
24372438
//2013 6 2 3群月王 ms-visible bug
2438-
//黄轩http://www.cnblogs.com/lcllao/archive/2012/09/30/2709187.html
2439+
//黄轩http://www.cnblogs.com/lcllao/archive/2012/09/30/2709187.html

0 commit comments

Comments
 (0)