Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on') #836

Open
hexadecy opened this issue Feb 7, 2023 · 1 comment
Labels

Comments

@hexadecy
Copy link

hexadecy commented Feb 7, 2023

When I rename the 'router' to { 'host-router': 'router' } in all my engines.
https://ember-engines.com/docs/deprecations#-use-alias-for-inject-router-service-from-host-application

I have this error from ember-component-css:

route-styles.js:13 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on')
    at Object.initialize (route-styles.js:13:1)
    at index.js:127:1
    at Vertices.each (dag-map.js:192:1)
    at Vertices.walk (dag-map.js:121:1)
    at DAG.each (dag-map.js:66:1)
    at DAG.topsort (dag-map.js:72:1)
    at Class._runInitializer (index.js:139:1)
    at Class.runInstanceInitializers (index.js:125:1)
    at Class._bootSync (instance.js:86:1)
    at instance.js:63:1

ember-component-css/instance-initializers/route-styles.js
Error at the line:

router.on('routeDidChange', function (_ref) {

Full trace:

define("ember-component-css/instance-initializers/route-styles", ["exports", "ember-component-css/utils/init-route-styles"], function (_exports, _initRouteStyles) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _exports.initialize = initialize;
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  // This file is removed from the build in Ember < 3.6
  function initialize(appInstance) {
    var router = appInstance.lookup('service:router');
    router.on('routeDidChange', function (_ref) {
      var to = _ref.to;
      if (likeRouteInfo(to)) {
        (0, _initRouteStyles.default)(appInstance, nestedRouteNames(to));
      }
    });

Versions:

  • ember-source: 3.28.11
  • ember-engines: 0.8.23 or 0.9.0
  • ember-component-css: 0.8.1
  • Node 16
@SergeAstapov
Copy link
Contributor

Thanks @hexadecy for the detailed report! I wonder if using https://github.com/villander/ember-engines-router-service may be a temporary solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants