Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Transclusion fallback content with ng-if/ng-repeat cause js exception #14653

Closed
peterreisz opened this issue May 23, 2016 · 5 comments
Closed

Comments

@peterreisz
Copy link

In case I want to use directives which modifies the DOM structure (ng-if/ng-repeat) in the fallback content of the transclusion and I give another content when using the component, I've got an javascript exception, though the component seems working.

Angular version: 1.5.5
Plunkr: https://plnkr.co/edit/A4nxJDDy8OUBPc6hiVqq?p=info

angular.js:13550 TypeError: Cannot read property 'insertBefore' of null
    at forEach.after (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:3603:13)
    at Object.JQLite.(anonymous function) [as after] (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:3687:17)
    at domInsert (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:5229:35)
    at Object.enter (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:5397:9)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:25542:26
    at publicLinkFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8276:29)
    at lazyCompilation (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8615:25)
    at boundTranscludeFn (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:8414:16)
    at controllersBoundTransclude (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:9143:20)
    at ngIfWatchAction (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js:25533:15)
@Narretz Narretz self-assigned this May 23, 2016
@Narretz
Copy link
Contributor

Narretz commented May 23, 2016

Strange, this happens only when you use .component, not when you use .directive. Since component is built on directive, I wonder where the problem lies. Maybe there's timing difference where the component takes a bit longer to compile.

@gkalpak
Copy link
Member

gkalpak commented May 23, 2016

It does happen with directives too, as long as you use the same DDO properties.
Specifically, it seems to be the controllerAs: '$ctrl' that triggers it (and only for $ctrl !?!): plnkr

@yhorbachov
Copy link

I had same issue but with ng-repeat and component inside of it. I figure out that problem appears when we have unhandled exception during nodeLinkFn running (in my case in $onInit lifecycle hook), sooo if we have exception there, angular.js skips prelinking and postlinking routines and as result we have scope mess.

@jamie-pate
Copy link

jamie-pate commented Dec 29, 2016

With multi-element ng-repeat there is a similar problem: VM1362 angular.js:13236 Error: [$compile:uterdir] Unterminated attribute, found 'ng-repeat-start' but no matching 'ng-repeat-end' found.
plnkr

@gkalpak
Copy link
Member

gkalpak commented Dec 29, 2016

From a quick check the original issue seems to be fixed in 1.5.8 and works as expected till the latest 1.5.10 (demo).
The issue reported by @jamie-pate is totally unrelated (but still a valid issue). Let's track it in #15554.

@gkalpak gkalpak closed this as completed Dec 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants