ember.js: Error in 2.7.0 but not 2.6.0: Uncaught Error: Assertion Failed: Attempted to register a view with an id already in use: null

Updated

The bug is that since elementId is now conditionally initialized based on tagName (was this way in 1.12 and below), if the tagName is inherited as ‘’ and you set it again post this._super(...arguments);, then elementId === null but since tagName is now set to not be "" then when the view is registered, it will be registered as "null" causing problems if you render more than one.


When using Ember 2.7.0

When there are two instances of the same component used in a template the error of Uncaught Error: Assertion Failed: Attempted to register a view with an id already in use: null is thrown.

If the component is used in a parent route’s template as well as the child’s, when navigating away these deprecations are thrown:

DEPRECATION: A property of <regressionDemo@view:-outlet::ember413> was modified inside the didInsertElement hook. You should never change properties on components, services or models during didInsertElement because it causes significant performance degradation. [deprecation id: ember-views.dispatching-modify-property]
        at logDeprecationStackTrace (http://localhost:4200/assets/vendor.js:16676:19)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:16783:7)
        at raiseOnDeprecation (http://localhost:4200/assets/vendor.js:16706:12)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:16783:7)
        at invoke (http://localhost:4200/assets/vendor.js:16799:7)
        at deprecate (http://localhost:4200/assets/vendor.js:16767:32)
        at Object.deprecate (http://localhost:4200/assets/vendor.js:29639:37)
        at Class.exports.default._emberMetalMixin.Mixin.create._Mixin$create.scheduleRevalidate (http://localhost:4200/assets/vendor.js:54123:22)
        at http://localhost:4200/assets/vendor.js:27891:32
7ember.debug.js:6568 DEPRECATION: A property of <regressionDemo@view:-outlet::ember413> was modified inside the didInsertElement hook. You should never change properties on components, services or models during didInsertElement because it causes significant performance degradation. [deprecation id: ember-views.dispatching-modify-property]
        at logDeprecationStackTrace (http://localhost:4200/assets/vendor.js:16676:19)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:16783:7)
        at raiseOnDeprecation (http://localhost:4200/assets/vendor.js:16706:12)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:16783:7)
        at invoke (http://localhost:4200/assets/vendor.js:16799:7)
        at deprecate (http://localhost:4200/assets/vendor.js:16767:32)
        at Object.deprecate (http://localhost:4200/assets/vendor.js:29639:37)
        at Class.exports.default._emberMetalMixin.Mixin.create._Mixin$create.scheduleRevalidate (http://localhost:4200/assets/vendor.js:54123:22)
        at http://localhost:4200/assets/vendor.js:27891:32
ember.debug.js:6568 DEPRECATION: A property of <regressionDemo@view:-outlet::ember413> was modified inside the didInsertElement hook. You should never change properties on components, services or models during didInsertElement because it causes significant performance degradation. [deprecation id: ember-views.dispatching-modify-property]
        at logDeprecationStackTrace (http://localhost:4200/assets/vendor.js:16676:19)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:16783:7)
        at raiseOnDeprecation (http://localhost:4200/assets/vendor.js:16706:12)
        at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:16783:7)
        at invoke (http://localhost:4200/assets/vendor.js:16799:7)
        at deprecate (http://localhost:4200/assets/vendor.js:16767:32)
        at Object.deprecate (http://localhost:4200/assets/vendor.js:29639:37)
        at Class.exports.default._emberMetalMixin.Mixin.create._Mixin$create.scheduleRevalidate (http://localhost:4200/assets/vendor.js:54123:22)
        at Class.setOutletState (http://localhost:4200/assets/vendor.js:27941:14)

When using Ember 2.6.0

These problems do not occur.

How to reproduce

I have created an application recreating this setup, located at https://github.com/notmessenger/regressionDemo If you change the Ember version to 2.6.0 the errors will then go away.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Ok. I’ve been debugging the issue and here are some results:

  1. In ViewSupport#init, an elementId is generated if there is not one and tagName is different than the empty string.
  2. When a component enters the InDOM state, the view is registered if the tagName is not the empty string.

The problem is that between (1) and (2) a lot of things can happen changing the tagless consideration for the component.

I think this is an issue that requires at least two approaches to be fixed:

  1. Document and make sure people understand that components with tagName: '' are tagless and what the limitations are.
  2. Choose the point where a component needs to be marked as tagless and mark it in a way that cannot be modified later (as is happening now).

As 2.8 is getting closer, it might be quicker to add a test for this issue and modify ViewSupport to always generate an elementId.

Pinging @rwjblue because of this comment in a related close issue (#13627)

@Serabe @pixelhandler Upgrading to 2.8 resolves this issue. Sorry I didn’t get to this sooner.