Skip to content

Commit

Permalink
fix: child data cannot sync to parent in some case, closes #235
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzilong committed Jan 18, 2019
1 parent 3bbc847 commit 9da0f9c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
39 changes: 21 additions & 18 deletions dist/regular.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
return paramObj;
}
_.eventReg = /^on-(\w[-\w]+)$/;
_.eventReg = /^on-(\w[-\w]*)$/;

_.toText = function(obj){
return obj == null ? "": "" + obj;
Expand Down Expand Up @@ -4337,7 +4337,7 @@ return /******/ (function(modules) { // webpackBootstrap
}

if(!steps || !steps.length) return;

for(var i = 0; i < steps.length; i++){ //init

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

// oldKeyMap: 复用原来的节点
function updateTrack( newList, oldList, steps, rawNewValue, oldKeyMap ){

for(var i =0, slen = steps.length; i < slen ;i++){
var step = steps[i];
switch( step.mode){
Expand All @@ -4395,7 +4395,7 @@ return /******/ (function(modules) { // webpackBootstrap
addRange(step.index, step.index + step.len, newList, rawNewValue, oldKeyMap )
break;
}
}
}
var children = group.children;
for(var j=1, len = children.length; j < len; j++){
var child = children[j];
Expand All @@ -4405,7 +4405,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
}


}

function update(newValue, oldValue, steps, oldKeyMap, isSimple){
Expand All @@ -4431,13 +4431,13 @@ return /******/ (function(modules) { // webpackBootstrap
if(group.get(1)){
var altGroup = children.pop();
if(altGroup.destroy) altGroup.destroy(true);
}
}
return addRange(0, nlen, newList, rawNewValue )
}
// @ {#list} {#else}
if( !nlen ){
if(olen){
removeRange(0, olen, group.children)
removeRange(0, olen, group.children)
}
if(alternate && alternate.length){
var section = self.$compile(alternate, {
Expand All @@ -4455,7 +4455,7 @@ return /******/ (function(modules) { // webpackBootstrap
}

if(track){

if( track === true || (isSimple && !steps.length) ){ // track 可能走simple update
updateSimple( newList, oldList, rawNewValue );
}else{
Expand All @@ -4467,15 +4467,15 @@ return /******/ (function(modules) { // webpackBootstrap
}
updateTrack( newList, oldList , steps, rawNewValue, oldKeyMap);
}

}else{
updateLD( newList, oldList, steps, rawNewValue );
}

}

this.$watch(ast.sequence, update, {
init: true,
this.$watch(ast.sequence, update, {
init: true,
keyOf: keyOf,
diff: track!==true,
deep: true
Expand Down Expand Up @@ -4691,7 +4691,7 @@ return /******/ (function(modules) { // webpackBootstrap
tag = ast.tag,
Component = Constructor.component(tag),
ref, group, element, mountNode;




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


// if inititalized with mount mode, sometime,
// if inititalized with mount mode, sometime,
// browser will ignore the whitespace between node, and sometimes it won't
if(cursor ){
// textCOntent with Empty text
if(cursor.node && cursor.node.nodeType === 3){
if(_.blankReg.test(dom.text(cursor.node) ) ) cursor.next();
else if( !Component && tag !== 'r-component' ) {
throw Error(MSG[ERROR.UNMATCHED_AST]);
}
}
}
}

if(Component || tag === 'r-component'){
options.Component = Component;
return walkers.component.call(this, ast, options)
Expand Down Expand Up @@ -4816,7 +4816,7 @@ return /******/ (function(modules) { // webpackBootstrap
}


// @deprecated use
// @deprecated use
if(attr.mdf === 'cmpl'){
value = _.getCompileFn(value, this, {
record: true,
Expand All @@ -4833,7 +4833,7 @@ return /******/ (function(modules) { // webpackBootstrap
namespace: namespace,
extra: extra,
outer: options.outer
})
})
}

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

0 comments on commit 9da0f9c

Please sign in to comment.