Skip to content

Commit

Permalink
Fixed bug, when remove route, not remove triggers.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunins committed Jul 3, 2017
1 parent 27d21ee commit 880d7f8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 20 deletions.
14 changes: 11 additions & 3 deletions dist/docs/setRoutes.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ <h1>setRoutes.js</h1>
active = context.active,
matches = match(route),
oldParams = context.oldParams = context.oldParams || <span class="hljs-literal">false</span>,
routesQueried = context.routesQueried = context.routesQueried || [];
routesQueried = context.routesQueried = context.routesQueried || [],
childMatch = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>();

matches.to(<span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> {
<span class="hljs-keyword">let</span> params = args.pop();
Expand All @@ -189,10 +190,10 @@ <h1>setRoutes.js</h1>

</div>

<div class="content"><div class='highlight'><pre> match(route, match =&gt; matchRoute(instance, <span class="hljs-built_in">Object</span>.assign({}, context, {
<div class="content"><div class='highlight'><pre> childMatch.set(instance, match(route, match =&gt; matchRoute(instance, <span class="hljs-built_in">Object</span>.assign({}, context, {
match,
active
})));
}))));
}
});
}
Expand All @@ -214,6 +215,13 @@ <h1>setRoutes.js</h1>
<span class="hljs-keyword">if</span> (!id) {
dom.detach(childInstance);
} <span class="hljs-keyword">else</span> {
applyToChildren(childInstance.children, instance =&gt; {
<span class="hljs-keyword">const</span> childRoute = childMatch.get(instance);
<span class="hljs-keyword">if</span> (childRoute) {
childRoute.remove();
childMatch.delete(instance);
}
});
destroyComponent(childInstance);
}
},
Expand Down
14 changes: 11 additions & 3 deletions dist/es5/dev/widget/Constructor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/es5/dev/widget/Constructor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es5/prod/babel/polyfill.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/es5/prod/widget/App.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions dist/es6/dev/widget/Constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,8 @@ define('widget/parsers/setRoutes',[
active = context.active,
matches = match(route),
oldParams = context.oldParams = context.oldParams || false,
routesQueried = context.routesQueried = context.routesQueried || [];
routesQueried = context.routesQueried = context.routesQueried || [],
childMatch = new Map();

matches.to((...args) => {
let params = args.pop();
Expand All @@ -1009,10 +1010,10 @@ define('widget/parsers/setRoutes',[
applyToChildren(childInstance.children, instance => {
if (instance) {
//TODO: maybe not need Object.assign
match(route, match => matchRoute(instance, Object.assign({}, context, {
childMatch.set(instance, match(route, match => matchRoute(instance, Object.assign({}, context, {
match,
active
})));
}))));
}
});
}
Expand All @@ -1034,6 +1035,13 @@ define('widget/parsers/setRoutes',[
if (!id) {
dom.detach(childInstance);
} else {
applyToChildren(childInstance.children, instance => {
const childRoute = childMatch.get(instance);
if (childRoute) {
childRoute.remove();
childMatch.delete(instance);
}
});
destroyComponent(childInstance);
}
},
Expand Down
4 changes: 2 additions & 2 deletions dist/es6/prod/widget/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions src/widget/parsers/setRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ define([
active = context.active,
matches = match(route),
oldParams = context.oldParams = context.oldParams || false,
routesQueried = context.routesQueried = context.routesQueried || [];
routesQueried = context.routesQueried = context.routesQueried || [],
childMatch = new Map();

matches.to((...args) => {
let params = args.pop();
Expand All @@ -66,10 +67,10 @@ define([
applyToChildren(childInstance.children, instance => {
if (instance) {
//TODO: maybe not need Object.assign
match(route, match => matchRoute(instance, Object.assign({}, context, {
childMatch.set(instance, match(route, match => matchRoute(instance, Object.assign({}, context, {
match,
active
})));
}))));
}
});
}
Expand All @@ -91,6 +92,13 @@ define([
if (!id) {
dom.detach(childInstance);
} else {
applyToChildren(childInstance.children, instance => {
const childRoute = childMatch.get(instance);
if (childRoute) {
childRoute.remove();
childMatch.delete(instance);
}
});
destroyComponent(childInstance);
}
},
Expand Down

0 comments on commit 880d7f8

Please sign in to comment.