Angular Router 修改版本

Kevin c338f2f785 更新 'README.md' %!s(int64=5) %!d(string=hai) anos
bundles 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
esm2015 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
esm5 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
fesm2015 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
fesm5 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
src 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
testing 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
upgrade 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
README.md c338f2f785 更新 'README.md' %!s(int64=5) %!d(string=hai) anos
index.d.ts 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
package.json 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
public_api.d.ts 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
router.d.ts 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
router.metadata.json 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
testing.d.ts 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
testing.metadata.json 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
upgrade.d.ts 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos
upgrade.metadata.json 1fd1e2f0e4 上传项目 %!s(int64=5) %!d(string=hai) anos

README.md

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

License: MIT

改动

在 ActivateRoutes.prototype.activateRoutes添加了

ActivateRoutes.prototype.activateRoutes = function (futureNode, currNode, parentContexts) {
        var future = futureNode.value;
        var curr = currNode ? currNode.value : null;
        advanceActivatedRoute(future);
        // reusing the node
        if (future === curr) {
            if (future.component) {
                // If we have a normal route, we need to go through an outlet.
                var context = parentContexts.getOrCreateContext(future.outlet);
                this.activateChildRoutes(futureNode, currNode, context.children);
            }
            else {
                // if we have a componentless route, we recurse but keep the same outlet map.
                this.activateChildRoutes(futureNode, currNode, parentContexts);
            }
        }
        else {
            if (future.component) {
                // if we have a normal route, we need to place the component into the outlet and recurse.
                var context = parentContexts.getOrCreateContext(future.outlet);
                if (this.routeReuseStrategy.shouldAttach(future.snapshot)) {
                    var stored = this.routeReuseStrategy.retrieve(future.snapshot);
                    this.routeReuseStrategy.store(future.snapshot, null);
                    context.children.onOutletReAttached(stored.contexts);
                    context.attachRef = stored.componentRef;
                    context.route = stored.route.value;
                    if (context.outlet) {
                        // Attach right away when the outlet has already been instantiated
                        // Otherwise attach from `RouterOutlet.ngOnInit` when it is instantiated
                        context.outlet.attach(stored.componentRef, stored.route.value);
                    }
                    //region 原代码
                     advanceActivatedRouteNodeAndItsChildren(stored.route);
                    //endregion 
                    //region 改动后
                    if(context.children.contexts != null && context.children.contexts.size > 0){
                      this.activateChildRoutes(futureNode, null, context.children);
                      advanceActivatedRoute(stored.route.value);
                    }else{
                      advanceActivatedRouteNodeAndItsChildren(stored.route);
                    }
                    //endregion
                }
                else {
                    var config = parentLoadedConfig(future.snapshot);
                    var cmpFactoryResolver = config ? config.module.componentFactoryResolver : null;
                    context.attachRef = null;
                    context.route = future;
                    context.resolver = cmpFactoryResolver;
                    if (context.outlet) {
                        // Activate the outlet when it has already been instantiated
                        // Otherwise it will get activated from its `ngOnInit` when instantiated
                        context.outlet.activateWith(future, cmpFactoryResolver);
                    }
                    this.activateChildRoutes(futureNode, null, context.children);
                }
            }
            else {
                // if we have a componentless route, we recurse but keep the same outlet map.
                this.activateChildRoutes(futureNode, null, parentContexts);
            }
        }
    };
    return ActivateRoutes;
}());

具体效果