UNPKG

aurelia-bootstrap

Version:
74 lines (55 loc) 2.64 kB
/* */ define(['exports', 'aurelia-dependency-injection', 'aurelia-templating', 'aurelia-router', 'aurelia-path', 'aurelia-metadata'], function (exports, _aureliaDependencyInjection, _aureliaTemplating, _aureliaRouter, _aureliaPath, _aureliaMetadata) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.TemplatingRouteLoader = undefined; function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var _dec, _class; var TemplatingRouteLoader = exports.TemplatingRouteLoader = (_dec = (0, _aureliaDependencyInjection.inject)(_aureliaTemplating.CompositionEngine), _dec(_class = function (_RouteLoader) { _inherits(TemplatingRouteLoader, _RouteLoader); function TemplatingRouteLoader(compositionEngine) { var _this = _possibleConstructorReturn(this, _RouteLoader.call(this)); _this.compositionEngine = compositionEngine; return _this; } TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) { var childContainer = router.container.createChild(); var instruction = { viewModel: (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId), childContainer: childContainer, view: config.view || config.viewStrategy, router: router }; childContainer.getChildRouter = function () { var childRouter = void 0; childContainer.registerHandler(_aureliaRouter.Router, function (c) { return childRouter || (childRouter = router.createChild(childContainer)); }); return childContainer.get(_aureliaRouter.Router); }; return this.compositionEngine.ensureViewModel(instruction); }; return TemplatingRouteLoader; }(_aureliaRouter.RouteLoader)) || _class); });