Skip to content

Commit 9da0f9c

Browse files
committed
fix: child data cannot sync to parent in some case, closes #235
1 parent 3bbc847 commit 9da0f9c

File tree

3 files changed

+44
-39
lines changed

3 files changed

+44
-39
lines changed

dist/regular.js

+21-18
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ return /******/ (function(modules) { // webpackBootstrap
880880
}
881881
return paramObj;
882882
}
883-
_.eventReg = /^on-(\w[-\w]+)$/;
883+
_.eventReg = /^on-(\w[-\w]*)$/;
884884

885885
_.toText = function(obj){
886886
return obj == null ? "": "" + obj;
@@ -4337,7 +4337,7 @@ return /******/ (function(modules) { // webpackBootstrap
43374337
}
43384338

43394339
if(!steps || !steps.length) return;
4340-
4340+
43414341
for(var i = 0; i < steps.length; i++){ //init
43424342

43434343
var splice = steps[i];
@@ -4384,7 +4384,7 @@ return /******/ (function(modules) { // webpackBootstrap
43844384

43854385
// oldKeyMap: 复用原来的节点
43864386
function updateTrack( newList, oldList, steps, rawNewValue, oldKeyMap ){
4387-
4387+
43884388
for(var i =0, slen = steps.length; i < slen ;i++){
43894389
var step = steps[i];
43904390
switch( step.mode){
@@ -4395,7 +4395,7 @@ return /******/ (function(modules) { // webpackBootstrap
43954395
addRange(step.index, step.index + step.len, newList, rawNewValue, oldKeyMap )
43964396
break;
43974397
}
4398-
}
4398+
}
43994399
var children = group.children;
44004400
for(var j=1, len = children.length; j < len; j++){
44014401
var child = children[j];
@@ -4405,7 +4405,7 @@ return /******/ (function(modules) { // webpackBootstrap
44054405
}
44064406
}
44074407

4408-
4408+
44094409
}
44104410

44114411
function update(newValue, oldValue, steps, oldKeyMap, isSimple){
@@ -4431,13 +4431,13 @@ return /******/ (function(modules) { // webpackBootstrap
44314431
if(group.get(1)){
44324432
var altGroup = children.pop();
44334433
if(altGroup.destroy) altGroup.destroy(true);
4434-
}
4434+
}
44354435
return addRange(0, nlen, newList, rawNewValue )
44364436
}
44374437
// @ {#list} {#else}
44384438
if( !nlen ){
44394439
if(olen){
4440-
removeRange(0, olen, group.children)
4440+
removeRange(0, olen, group.children)
44414441
}
44424442
if(alternate && alternate.length){
44434443
var section = self.$compile(alternate, {
@@ -4455,7 +4455,7 @@ return /******/ (function(modules) { // webpackBootstrap
44554455
}
44564456

44574457
if(track){
4458-
4458+
44594459
if( track === true || (isSimple && !steps.length) ){ // track 可能走simple update
44604460
updateSimple( newList, oldList, rawNewValue );
44614461
}else{
@@ -4467,15 +4467,15 @@ return /******/ (function(modules) { // webpackBootstrap
44674467
}
44684468
updateTrack( newList, oldList , steps, rawNewValue, oldKeyMap);
44694469
}
4470-
4470+
44714471
}else{
44724472
updateLD( newList, oldList, steps, rawNewValue );
44734473
}
44744474

44754475
}
44764476

4477-
this.$watch(ast.sequence, update, {
4478-
init: true,
4477+
this.$watch(ast.sequence, update, {
4478+
init: true,
44794479
keyOf: keyOf,
44804480
diff: track!==true,
44814481
deep: true
@@ -4691,7 +4691,7 @@ return /******/ (function(modules) { // webpackBootstrap
46914691
tag = ast.tag,
46924692
Component = Constructor.component(tag),
46934693
ref, group, element, mountNode;
4694-
4694+
46954695

46964696

46974697

@@ -4701,18 +4701,18 @@ return /******/ (function(modules) { // webpackBootstrap
47014701
}
47024702

47034703

4704-
// if inititalized with mount mode, sometime,
4704+
// if inititalized with mount mode, sometime,
47054705
// browser will ignore the whitespace between node, and sometimes it won't
47064706
if(cursor ){
47074707
// textCOntent with Empty text
47084708
if(cursor.node && cursor.node.nodeType === 3){
47094709
if(_.blankReg.test(dom.text(cursor.node) ) ) cursor.next();
47104710
else if( !Component && tag !== 'r-component' ) {
47114711
throw Error(MSG[ERROR.UNMATCHED_AST]);
4712-
}
4712+
}
47134713
}
47144714
}
4715-
4715+
47164716
if(Component || tag === 'r-component'){
47174717
options.Component = Component;
47184718
return walkers.component.call(this, ast, options)
@@ -4816,7 +4816,7 @@ return /******/ (function(modules) { // webpackBootstrap
48164816
}
48174817

48184818

4819-
// @deprecated use
4819+
// @deprecated use
48204820
if(attr.mdf === 'cmpl'){
48214821
value = _.getCompileFn(value, this, {
48224822
record: true,
@@ -4833,7 +4833,7 @@ return /******/ (function(modules) { // webpackBootstrap
48334833
namespace: namespace,
48344834
extra: extra,
48354835
outer: options.outer
4836-
})
4836+
})
48374837
}
48384838

48394839
// @if is r-component . we need to find the target Component
@@ -4911,7 +4911,10 @@ return /******/ (function(modules) { // webpackBootstrap
49114911
}).bind(component, name), OPTIONS.SYNC)
49124912
if( value.set && !(isolate & 1 ) )
49134913
// sync the data. it force the component don't trigger attr.name's first dirty echeck
4914-
component.$watch(name, self.$update.bind(self, value), OPTIONS.INIT);
4914+
component.$watch(name, self.$update.bind(self, value), {
4915+
init: true,
4916+
last: this.data[ name ]
4917+
});
49154918
}
49164919
}
49174920
if(is && is.type === 'expression' ){

0 commit comments

Comments
 (0)