Skip to content

Commit

Permalink
对二维数组项repeat时,变换下标不能触发视图更新,并且更新前后数组长度一样时不能更新
Browse files Browse the repository at this point in the history
  • Loading branch information
qitmac000408 authored and qitmac000408 committed Oct 13, 2015
1 parent fef2d1d commit 51cb4cf
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 22 deletions.
12 changes: 10 additions & 2 deletions avalon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.js 1.4.7 built in 2015.10.12
avalon.js 1.4.7 built in 2015.10.13
support IE6+ and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -4158,6 +4158,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -4226,7 +4229,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
12 changes: 10 additions & 2 deletions dist/avalon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.js 1.4.7 built in 2015.10.12
avalon.js 1.4.7 built in 2015.10.13
support IE6+ and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -4158,6 +4158,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -4226,7 +4229,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
2 changes: 1 addition & 1 deletion dist/avalon.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions dist/avalon.mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.mobile.js 1.4.7 built in 2015.10.12
avalon.mobile.js 1.4.7 built in 2015.10.13
support IE10+ and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -3476,6 +3476,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -3544,7 +3547,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
4 changes: 2 additions & 2 deletions dist/avalon.mobile.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions dist/avalon.mobile.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.mobile.old.js 1.4.7 built in 2015.10.12
avalon.mobile.old.js 1.4.7 built in 2015.10.13
support IE8 and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -4158,6 +4158,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -4226,7 +4229,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
12 changes: 10 additions & 2 deletions dist/avalon.mobile.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.mobile.shim.js 1.4.7 built in 2015.10.12
avalon.mobile.shim.js 1.4.7 built in 2015.10.13
==================================================*/
(function(global, factory) {

Expand Down Expand Up @@ -3475,6 +3475,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -3543,7 +3546,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
12 changes: 10 additions & 2 deletions dist/avalon.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.modern.js 1.4.7 built in 2015.10.12
avalon.modern.js 1.4.7 built in 2015.10.13
support IE10+ and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -3476,6 +3476,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -3544,7 +3547,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
2 changes: 1 addition & 1 deletion dist/avalon.modern.min.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions dist/avalon.modern.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.modern.shim.js(无加载器版本) 1.4.7 built in 2015.10.12
avalon.modern.shim.js(无加载器版本) 1.4.7 built in 2015.10.13
support IE10+ and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -3476,6 +3476,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -3544,7 +3547,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
12 changes: 10 additions & 2 deletions dist/avalon.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
http://weibo.com/jslouvre/
Released under the MIT license
avalon.shim.js(无加载器版本) 1.4.7 built in 2015.10.12
avalon.shim.js(无加载器版本) 1.4.7 built in 2015.10.13
support IE6+ and other browsers
==================================================*/
(function(global, factory) {
Expand Down Expand Up @@ -4158,6 +4158,9 @@ bindingHandlers.repeat = function (data, vmodels) {
}
}

data.handler = noop
avalon.injectBinding(data)

var elem = data.element
if (elem.nodeType === 1) {
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -4226,7 +4229,12 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
return
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
}
}
method = "add"
pos = 0
Expand Down
4 changes: 2 additions & 2 deletions src/19 directive/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ bindingExecutors.repeat = function (method, pos, el) {

if (data.xtype === "array") {
if (old.length === neo.length) {
if (old != neo && old.length > 0) {
arguments.callee.call(this, 'clear', pos, el)
if (old !== neo && old.length > 0) {
bindingExecutors.repeat.call(this, 'clear', pos, el)
}
else {
return
Expand Down

0 comments on commit 51cb4cf

Please sign in to comment.